mcat.c

#include <stdio.h>
#include <string.h>

char *dyngets(char *, int, FILE *);

void filedump(FILE *f)
{
	char *in;
	int i = 0;

	while((in = dyngets(NULL, 20, f)) != NULL){
		i += 1;
		printf("%4d; length %3d: \"%s\"", 20 * i, (int)strlen(in), in);
	}
}
	
int main(int argc, char *argv[])
{
	int i;
	FILE *fp;

	for(i = 1; i < argc; i++){
		if ((fp = fopen(argv[i], "r")) != NULL){
			filedump(fp);
			fclose(fp);
		}
		else
			perror(argv[i]);
	}

	return(0);
}


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 36A, Programming & Problem Solving
Version of April 2, 2024 at 12:13PM

You can get the raw source code here.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh