delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/30/14:47:51

From: kagel AT quasar DOT bloomberg DOT com
Date: Thu, 30 May 1996 13:24:21 -0400
Message-Id: <9605301724.AA03701@quasar.bloomberg.com >
To: rkwcvdz AT rivier1 DOT puk DOT ac DOT za
Cc: djgpp AT delorie DOT com
In-Reply-To: <46251.rkwcvdz@rivier1.puk.ac.za>
Subject: Re: Moving from Pascal to Djgpp
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   From: <rkwcvdz AT rivier1 DOT puk DOT ac DOT za>
   Date: Wed, 29 May 96 09:01:36

       #include <stdio.h>

	int main(void);
	void exit(int);

	int main(void)
   {
     int c;
      File *fin, *fout;
      ^^^^
      Here is your problem.  The typedef is FILE not File.  This should be:
      FILE *fin, *fout;

      fin = fopen("in.dat", "r");
      if (fin == NULL) {
       printf("Unable to open file in.dat\n");
       exit(1);
       }

     fout = fopen("out.dat", "w");
     if (fout == NULL) {
      printf("unable to open file out.dat\n");
      exit(2);
       }
     while ((c=fgetc(fin)) != EOF) {
      if (fputc(c, fout) != c) {
       printf("Error writing out.dat\n");
       exit(3);
      }
    }
   fclose(fin);
   fclose(fout);
   return 0;
   }

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


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