Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cwjcc!ukma!uflorida!haven!aplcen!jhunix!c08_d103 From: c08_d103@jhunix.HCF.JHU.EDU (Ex-God) Newsgroups: comp.lang.c Subject: Re: Args to C progs?? Keywords: Turbo C Message-ID: <993@jhunix.HCF.JHU.EDU> Date: 6 Mar 89 01:08:33 GMT References: <9600003@silver> Reply-To: c08_d103@jhunix.UUCP (Ex-God) Organization: The Johns Hopkins University - HCF Lines: 30 In article <9600003@silver> mitchemt@silver.bacs.indiana.edu writes: > > I am writing a program in Turbo C and would like to know how to pass >arguments to it from the command line after it is compiled to a .exe file. > >I have tried: > >main(arg1) >char *arg1; Well, I don't know Turbo C, but if it's reasonably standard, it should pass an integer and an array of strings. Try main (argc, argv) int argc; char *argv[] Then argv[0] will hold the command name, argv[1] will hold the first argument, etc. As far as I know, there's no definition for what makes an argument, but in Unix, it's a word separated by white space. Oh, argc will hold the number of arguments (including the command name). For more information, check K&R1 5.11 (p110-114) or K&R2 5.10 (p114-118). If someone knows Turbo C better than I do, tell me if that will work.... -- Andrew Barnert (Andy Social/Andy Christ/Andy Matter/ex-God) ins_balb@jhunix/ins_balb@jhuvms/c08_d103@jhunix The opinions expressed in this message are yours. "If you can't stand the Big Chill, burn down the freezer." -- Jello Biafra