www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/10/18:50:19

Message-ID: <37375B3F.4281@ns.sympatico.ca>
From: Klaas <klaas AT ns DOT sympatico DOT ca>
X-Mailer: Mozilla 3.04 (Win95; I)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need Help with writing to disk files!
References: <37374DD2 DOT B532713C AT sginet DOT com> <37375A59 DOT 39A0 AT ns DOT sympatico DOT ca>
Lines: 35
Date: Mon, 10 May 1999 19:18:39 -0300
NNTP-Posting-Host: 142.177.71.1
X-Trace: sapphire.mtt.net 926375030 142.177.71.1 (Mon, 10 May 1999 19:23:50 ADT)
NNTP-Posting-Date: Mon, 10 May 1999 19:23:50 ADT
Organization: Sympatico-Subscriber
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Klaas wrote:
> 
> Don Wilkinson wrote:
> >
> > What is the best way to create disk files in a program and write to it?
> > I would greatly appreciate the help.
> >


oops! forgot:

 f=fopen("filename.ext","w");

use this before writing to file, sorry

> #include <stdio.h>
> 
> void main() {
>         FILE *f;
>         int i=23000;
>         char c=100;
> 
>         //now use fputi,fputc,fputs,etc.
> 
>         //ex. write a char to the file
>         fputc(f,c);
> 
>         //write an int to the file
>         fputi(f,i);
> 
>         //use this to close the file
>         close(f);
> 
>         exit(0);
>         }

- Raw text -


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