File:  [MW Coherent from dump] / coherent / b / lib / libc / XSTDIO / test / copy.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:36 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * copy.c
 * 11/4/92
 */

#include <stdio.h>

extern	void	fatal();

FILE *ifp, *ofp;

main(argc, argv) int argc; char *argv[];
{
	register int c;

	if (argc != 3)
		fatal("Usage: copy in out");
	if ((ifp = fopen(argv[1], "r")) == NULL)
		fatal("copy: cannot open input file");
	if ((ofp = fopen(argv[2], "w")) == NULL)
		fatal("copy: cannot open input file");
	while ((c = getc(ifp)) != EOF)
		putc(c, ofp);
	printf("feof(ifp)=%d\n", feof(ifp));
	printf("ferror(ifp)=%d\n", ferror(ifp));
	printf("ferror(ofp)=%d\n", ferror(ofp));
	fclose(ifp);
	fclose(ofp);
	exit(0);	
}

/* VARARGS */
void
fatal(msg) char *msg;
{
	fprintf(stderr, "%s\n", msg);
	exit(1);
}

/* end of copy.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.