c - A fscanf is making a error in a if condition -


i have problem in 1 function. in there open .txt (wich opens right, , start save variables until if. enter in condition doesn't sfanf. program can build , run until passes function. says problem in coments above fscanf error is. previous code workking should.

ppac le_pacientes(char *nomefich){ ppac lipac=null,novo,aux=lipac; pac pacientes; file *f;  f=fopen(nomefich,"rt"); if(!f){     printf("erro ao abrir ficheiro\n");     return null; }  pacientes.prox=null;  while(fscanf(f,"%100[^\n]",pacientes.nome)==1){         fscanf(f,"%d-%d-%d",&pacientes.dn,&pacientes.mn,&pacientes.an);       pacientes.idade = verifica_idade(lipac);      fscanf(f,"%d consultas",&pacientes.nconsult);     if(pacientes.nconsult>=2)     {         ///  !!!!problem!!!!  ///         fscanf(f,"%s",pacientes.tipoc1);printf("hello\n\n");         //fscanf(f,"%d/%d/%d -",&pacientes.dc1,                // &pacientes.mc1,&pacientes.ac1);         //fscanf(f," %100[^\n]",pacientes.nomemed1);          //fscanf(f,"%s - %d/%d/%d - ",pacientes.tipoc2,&pacientes.dc2,                 //&pacientes.mc2,&pacientes.ac2);         //fscanf(f," %100[^\n]",pacientes.nomemed2);     }     /*else if(pacientes.nconsult==1)     {         fscanf(f,"%c - %d/%d/%d - ",pacientes.tipoc1,&pacientes.dc1,                 &pacientes.mc1,&pacientes.ac1);         fscanf(f," %100[^\n]",pacientes.nomemed1);     }*/     printf("hello\n\n");     novo=malloc(sizeof(pac));     if(!novo){         printf("erro alocar memoria\n");         fclose(f);         return lipac;     }      *novo=pacientes;     if(!lipac)         lipac=novo;     else         aux->prox=novo;     aux=novo;  }  return lipac; 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -