Seriously, I'm gonna end up in a madhouse!
This is my function:
Code:
int get_data(FILE *pf){
int data=0;
char line[CHAR];
char last_line[CHAR];
char empty_line[CHAR]="\n";
while(fgets(line,sizeof line,pf)){
if(strcmp(line,empty_line)!=0)
strcpy(last_line,line);
}
sscanf(last_line,"Total sencillos = %d",&data);
return data;
where CHAR represents 140.
This is my function call:
Code:
int total_sencillos=0;
pf=fopen("BONOSSENCILLOS.txt","a");
total_sencillos=get_data(pf);
total_sencillos++;
fprintf(pf,"Total sencillos=%d\n",total_sencillos);
return pf;
}
And it keeps reading 0 and writing 1, time after time
I'm a few hours away from smashing my computer