Mail Archives: djgpp/1998/11/04/23:20:48
This has had me puzzled for awhile, its a program designed to replace
the dos"type"command, but allows wildcards
please email to author...thanx in advance
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int count=1;
char x;
int show_file(int count,char *argv[]);
char *main(int argc, char *argv[]) {
if(argc<2)
{
fprintf(stderr,"Not enough arguments.\n");
exit(1);
}
for(count=2;count<argc;count++)
{
printf("Count before passing: %d",count);
count++;
show_file(count,argv);
}
return;
}
int show_file(int count,char *argv[]) {
FILE *in;
printf("\nShow count");
printf("\n%d\n",count);
puts("show filename");
printf("\n%s\n",argv[count]);
puts("opening");
if((in=fopen(argv[count],"r"))==NULL);
{
fprintf(stderr,"Cannot open %s, aborting...\n",argv[count]);
exit(1);
}
puts("starting display");
while(!feof(in)) {
x=getc(in);
putchar(x);
}
fclose(in);
return;
}
- Raw text -