Mail Archives: djgpp/2000/05/01/23:08:32
I want to read 2 values from a text file, modify them and write them back.
I placed them alone on a line each so the file looked like this
12
45
that was all, but I couldn't figure out how, so I wrote the text file as
a12
c45
that way I could search for a and take the number following, and likewise
with c, but none of these things worked, is there a way to do this? how
would I go about it thanks.
if ((fp = fopen("c:\\text.txt","rt")) == NULL)
{
printf("Error opening file text.txt\n");
}
if(write!=1)
{
//here is the place to read in added and counted
//dos_read fread(added_int,size?,1,fp); these are wrong
//fread(counted_int,size?,1,fp);
for(i=0;(c=fgetc(fp))!=EOF&&i<1000;++i)
data[i]=(char)c;
for(c=0;c<i;++c)
if(data[c]=='a'){added_int=data[c+1];}
if(data[c]=='c'){counted_int=data[c+1];}
}
fclose(fp);
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
- Raw text -