Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!mephisto!ncsuvx!mcnc!unccvax!cs00jmc From: cs00jmc@unccvax.UUCP (John Covington WN4BBJ) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: redirection indicated in argc Message-ID: <1835@unccvax.UUCP> Date: 16 Feb 90 18:07:15 GMT References: <1022@wubios.wustl.edu> Reply-To: cs00jmc@unccvax.UUCP (John Covington WN4BBJ) Organization: University of North Carolina at Charlotte Lines: 32 In article <1022@wubios.wustl.edu> david@wubios.UUCP (David J. Camp) writes: >I was using Microsoft C, and had a program that used command line >arguments and read the standard input. When I specified: > > command arg1 arg2 ... argn-1 < filename > >The argc variable reflected the presence of the filename. >i.e. it had the value n+1. >When I specified: > > type filename | command arg1 arg2 ... argn-1 > >it was not indicated, i.e. it had the value n. I think this must >be a compiler bug. -David- > Actually, argc does not indicate the presence of filename at all. In C programs argv[0] is supposed to point to the name of the program currently being run (in this case command). Thus argc will always be at least 1. If arg1 is present then argc = 2, etc. Filename is never passed to the program because DOS opens the file and attaches it to stdin. --John -- John Covington WN4BBJ E-mail: cs00jmc@unccvax.uncc.edu P.O. Box 217122 MCI Mail: JCOVINGTON 342-6957 Charlotte, NC 28221-7122 Packet Radio: WN4BBJ @ W4BFB (704) 537-7653 Voice Mail: (704) 535-5404 mbx 3407 "Hugo Was Here" 9/22/89 "Give it back, Eric, it's not yours" (the ICOM)