delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/14/19:23:37

Message-ID: <000901bf0096$cff07540$44f243c3@marocky>
From: "Hakan Venderlof" <grok AT telia DOT com>
To: <djgpp AT delorie DOT com>
Subject: more on variables - what includes
Date: Fri, 17 Sep 1999 00:57:06 +0200
Organization: grok computer
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Reply-To: djgpp AT delorie DOT com

What include should be used for this?


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);



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  ***


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019