Mail Archives: djgpp/1999/09/16/00:06:08
| From: | Martin Ambuhl <mambuhl AT earthlink DOT net>
|
| Newsgroups: | comp.os.msdos.djgpp
|
| Subject: | Re: more on variables - what includes
|
| Date: | Wed, 15 Sep 1999 21:12:41 -0400
|
| References: | <000901bf0096$cff07540$44f243c3 AT marocky>
|
| X-Posted-Path-Was: | not-for-mail
|
| X-Accept-Language: | en
|
| X-ELN-Date: | 16 Sep 1999 01:10:41 GMT
|
| X-ELN-Insert-Date: | Wed Sep 15 18:15:12 1999
|
| Organization: | Nocturnal Aviation
|
| Lines: | 44
|
| Mime-Version: | 1.0
|
| NNTP-Posting-Host: | dialup-209.246.66.90.newyork2.level3.net
|
| Message-ID: | <37E04409.2B677F77@earthlink.net>
|
| X-Mailer: | Mozilla 4.61 [en] (Win95; U)
|
| To: | djgpp AT delorie DOT com
|
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
| Reply-To: | djgpp AT delorie DOT com
|
Hakan Venderlof wrote:
>
> What include should be used for this?
#include <stdio.h> /* or <cstdio> in C++ */
will define FILE, fopen, fscanf, fprintf, and fclose (among others) for
you.
>
> 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 ***
--
Martin Ambuhl mambuhl AT earthlink DOT net
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com
- Raw text -