Well I'm reading a file with the formatting of type:
name.txt names columns columns types
Where I can read all these strings, but when printing them, for example in a line with two column names and their respective two types, printf only shows the first two strings and in sequence two nulls . Here is the code:
char **tipos_coluna;
tipos_coluna = malloc(sizeof(char*)*(2*qtd_colunas)); //Matriz de strings alocada dinamicamente
for (int i = 0; i < qtd_colunas; ++i)
{
tipos_coluna[i] = malloc(sizeof(char)*20);
}
FILE *colunas_tabelas = fopen("colunas_tabelas/colunas_tabelas.txt", "r");
char validar[50];
while((fscanf(colunas_tabelas, "%s\n", validar)) != EOF)
{
if( !(strcmp(validar,tabela_url)) )
{
int i=0;
while((fscanf(colunas_tabelas, " %s", tipos_coluna[i])) != EOF)
{
if(i == (2*qtd_colunas)-1){
break;
}
++i;
}
}
}
fclose(colunas_tabelas);
for (int i = 0; i < 2*qtd_colunas; ++i)
{
printf("%s ", tipos_coluna[i]);
}
printf("\n");