Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!cornell!rochester!uhura.cc.rochester.edu!ur-valhalla!chan From: chan@galaxy.ee.rochester.edu (Daniel Chan) Newsgroups: comp.lang.c Subject: Re: Args to C progs?? Message-ID: <1867@valhalla.ee.rochester.edu> Date: 5 Mar 89 05:08:04 GMT References: <9600003@silver> Sender: usenet@valhalla.ee.rochester.edu Reply-To: chan@ee.rochester.edu (Daniel Chan) Organization: UR Dept. of Electrical Engg, Rochester NY 14627 Lines: 40 >From: mitchemt@silver.bacs.indiana.edu >Date: 4 Mar 89 22:57:00 GMT >Organization: Indiana University CSCI, Bloomington > 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; >{ >...... > /* do something with arg1 here */ >..... >} >Unfortunately, the program doesn't seem to recognize arg1. If I pass it a >string arg1 is just empty. Any help is appreciated. I just want to pass a >string to the program. > Thanks in advance, > TM Have you tried the following: main (argc, argv) int argc; /* total number of arguements including program name itself */ char *argv[]; /* an array of strings */ { ... } The command line arguments can then be accessed by argv[1], argv[2], ..., argv[argc-1]. Hope that will work in Turbo C. -dan.