#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);
}
|
ECS 36A, Programming & Problem Solving Version of April 2, 2024 at 12:13PM
|
You can get the raw source code here. |