-1
Guys, I’m trying to copy a file that has several products, a line with the name and the following with the code, price and quantity. I tried to pass each line to an array, but it’s not working. When I print, it’s not correct.
fp = fopen("Produtos.txt","r");
if ((fp = fopen("Produtos.txt","r")) == NULL ){
printf("Erro na abertura do arquivo!!!!");
return (0);
}
while (1){
if(feof(fp)) break;
fgets(nome_prod[i],100,fp);
fgets(cod_prod[i],100,fp);
fscanf(fp,"%f",&preco_prod[i]);
fscanf(fp,"%d",&quant_prod[i]);
i++;}
C is different from C#, please use the tags correctly.
– Jéf Bueno
how you are declaring the variables name_prod and cod_prod?
– Hiago Souza
char nome_prod[1000][100];
– Bjlli
char cod_prod[1000][100];
– Bjlli
You could show an example of input formatting?
– JJoao