Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command line arguments

Status
Not open for further replies.

tmadhavi17

Programmer
Joined
Oct 21, 2002
Messages
4
Location
GB
Hi there!
I am new to c language and especially in dealing with command line arguments. I came across a program which takes a dir name as argument. I got a doubt at the point where they were doing some validation like this and was quite puzzled of why they compared it so..

if (! strcmp(argv[1],"/?")){
printf("\nUsage:\>directory for xxx - Alpha Numeric, 8 or less chars)\n\n");
exit(0);
}

If I have to do it, I thought that I will check if "argc>1" or not (ofcourse, they did this too).

Any ideas what does comparing argv with "?" does mean??

cheers
-M

 
Because it is more or less a de-facto standard that one can ask the program to display the possible arguments / switches etc.
Normally you will use '/?' for this.

Example :

myprogram.exe /?

Could produce this output ... or whatever .... :
Usage : myprogram inputfile outputfile
/JOlesen
 
Thanks Jolesen!
That clears my mind.

cheers
-M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top