Mail Archives: djgpp/1999/09/13/20:52:22
Hakan Venderlof wrote:
>
> Hello
> I would like to load an variable from a file
> 'variable.txt' looking like this:
>
> 25
>
> and then change the variable in a program and
> save the variable to the samefile, eg overwriting the file
> to for example
>
> 50
>
> How should this be written?
>
> *** greetings grok sweden ***
FILE *f;
int v;
f = fopen("variable.txt", "rt");
fscanf(f, "%d", &v);
fclose(f);
f = fopen("variable.txt", "wt");
fprintf(f, "%d\n", v);
fclose(f);
--
Nate Eldredge
neldredge AT hmc DOT edu
- Raw text -