www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/04/23:20:48

From: thezr0 AT aol DOT com (The zr0)
Newsgroups: comp.os.msdos.djgpp
Subject: whats wrong w/ this code?
Lines: 54
NNTP-Posting-Host: ladder01.news.aol.com
X-Admin: news AT aol DOT com
Date: 5 Nov 1998 04:15:13 GMT
Organization: AOL http://www.aol.com
Message-ID: <19981104231513.27592.00001445@ng84.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019