delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/05/02:30:20

From: "Robert ARSENIUK" <arsen AT friko2 DOT onet DOT pl>
To: <djgpp AT delorie DOT com>
Subject: Re: whats wrong w/ this code?
Date: Thu, 5 Nov 1998 08:28:21 +0100
Message-ID: <01be088d$ddaf3290$0113010a@robi1.jmpolska.com>
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.71.1712.3
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Reply-To: djgpp AT delorie DOT com

-----Wiadomo¶ć orginalna-----
Od: The zr0 <thezr0 AT aol DOT com>
Grupy dyskusyjne: comp.os.msdos.djgpp
Do: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Data: 5 listopada 1998 05:33
Temat: whats wrong w/ this code?


>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;
>}
>
>
>

Change loop like this :

    for(count=2;count<argc;count++)
    {
        ...
    }

Robert


- Raw text -


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