I still can't understand why this printf is printing many 0 and the i++ is having no effect
int i=0;
char datos[5]="";
while((fscanf(entry_file,"%5s",datos))==1)
{
//Buffer para @
char x;
if((strcmp(datos,"DATOS"))==0)
{
fscanf(entry_file,"%lf%c%lf%c%lf%c%lf%c%lf%c%lf%c%lf",&cohetes[numCohetes].vuelos[0].aceleracionX[i],&x,&cohetes[numCohetes].vuelos[0].aceleracionY[i],&x,&cohetes[numCohetes].vuelos[0].aceleracionZ[i],
&x,&cohetes[numCohetes].vuelos[0].altura[i],&x,&cohetes[numCohetes].vuelos[0].potencia[i],&x,&cohetes[numCohetes].vuelos[0].temperatura[i],&x,&cohetes[numCohetes].vuelos[0].tiempo[i]);
printf("%d\n",i);
i++;
datos[0]='\0';
}
}
Your variable datos
is too small, so the ending null character is overwriting i
.
Change the decalaration to:
char datos[6]="";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.