Hi!, i'm new with c, sorry if it's a newbie question, but i can't find an answer.
I have some Ints declared, and after that I am using a sscanf (with some buffers), but sscanf is modifing the previously declared ints, why that is happening?
Here is my code:
Code:
...
int xivn=0; //here i declare the ints (i never modify this values)
int xivt=0;
int xiv=0;
int xivf=0;
if (archivo!= NULL){
char linea [128];
char resto0 [20];
char resto1 [20];
char resto2 [20];
while (fgets(linea,sizeof(linea),archivo)!=NULL){
sscanf(linea,"%s %s %s %s", c0, resto0, resto1, resto2); //if i comment this line i can see the values of the ints unmodified
}
fclose(archivo);
}else{
perror(nombrearchivo);
return 1;
}
printf("xivn:%d, xivt:%d, xiv:%d, xivf:%d \n\n",xivn,xivt,xiv,xivf); //it prints xivn:0, xivt:47, xiv:1919221868, xivf:1953326451 :(
I'll really appreciate if someone can help me.
Thank you!