JyCet
Member
hi all,
I never writed in a formatted text file, so i've a pb to write correctly in my text file :unsure:
my formatted file is like that:
here my idea for the C code:
the pb is fputs write the correct information but not at the correct place, it's writed on the next line.
Any idea to return at the correct SEEK place to write at the correct place ? With fseek and ftell ?
thank
I never writed in a formatted text file, so i've a pb to write correctly in my text file :unsure:
my formatted file is like that:
Code:
# information
# blablabla
option1 0
# blablabla2
option2 0
# blablabla3
option3 0
...
here my idea for the C code:
Code:
if ((fp = fopen("rage2x.cfg", "r+")) != NULL){
while(fgets(ligne,sizeof(ligne),fp) != NULL){
sscanf(ligne, "%s %d", &arg1,&argd);
if (strcmp(arg1,"#")!=0){
if (strcmp(arg1,"option1")==0){
sprintf((char*)g_string, "option1 %d",option1);
fputs(g_string,fp);
}
else if (strcmp(arg1,"option2")==0){
sprintf((char*)g_string, "option2 %d",option2);
fputs(g_string,fp);
}
else if (strcmp(arg1,"option3")==0){
sprintf((char*)g_string, "option3 %d",option3);
fputs(g_string,fp);
}
}}}
the pb is fputs write the correct information but not at the correct place, it's writed on the next line.
Any idea to return at the correct SEEK place to write at the correct place ? With fseek and ftell ?
thank