C problems

George Armhold armhold at topaz.rutgers.edu
Tue May 30 11:40:23 AEST 1989


I started using my C compiler today (Manx Aztec V3.6a), and I'm really
frustrated with I/O. I have the K&R book, _Understanding C_ by Bruce
Hunter, as well as the documentation that came with Manx. All three of
them left me bewildered with the various file I/O conventions. There's
open, fopen, creat, etc... Which do I use when? What about writing to
the console? Can anyone recommend a GOOD book that explains the
various methods of I/O and also points out differences between
"standard" and "machine specific"? 

Also, here's some source I tried today. What I'm trying to do is
simply copy one file to another. When I compile it, I get error 125
which means "too many subscripts or indirection on integer". It occurs
wherever I mention argv[x].

#include <stdio.h>
main(argc, argv)
{
	int c;
	FILE *fp1, *fp2;
		       	
	if ((fp1=fopen(argv[1], "r"))==NULL) {
		printf("Can't open %s", argv[1]);
		exit();
		}

	if ((fp2=fopen(argv[2], "w"))==NULL) {
		printf("Can't open %s", argv[2]);
		exit();
		}
	
	while ((c=getc(fp1)!=EOF)) 
		putc(fp2);

}

Thanks
-George



More information about the Comp.lang.c mailing list