www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/12/17:45:47

From: iiibanezii AT aol DOT com (IIibanezII)
Newsgroups: comp.os.msdos.djgpp
Subject: Binary File Operations
Lines: 24
Message-ID: <1998091221320200.RAA14256@ladder01.news.aol.com>
NNTP-Posting-Host: ladder01.news.aol.com
Date: 12 Sep 1998 21:32:02 GMT
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have been trying to learn binary file operations by making a file that gets a
string as input and writes it to a binary file, and then a second program which
reads from a binary file. Could someone please tell me what I am doing wrong?
Here's the code:

#include <stdio.h>

int main(void)
{
char string[100];
FILE *test;
test = fopen("test.dat", "wb");
printf("Text:");
fgets(string, 1, stdin);
fwrite(string, 1, 100, test);
fclose(test)
return 0;
}


The other program is similar except it reads from the file. Could somebody
please help me, thanks in advance,

IIibanezII AT aol DOT com

- Raw text -


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