954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Command Line Parameter

I WANT OT KNOW HOW TO WRITE APROGRAM WHICH IS GIVEN ONE OR MORE STRING AS COMMAND LINE PARAMETER AND WHICH BUILDS A LINKED LIST HOLDING COPIES OF THOSE STRING (I.E EACH NODE IN THE LIST SHOULD CONTAIN A STRING AND A POINTER TO THE NEXT NODE). tHE ORDER IN WHICH THEPARAMETERS ARE HELD IN THE LIST IS UNIMPORTANT.
(DON'T FORGET MENTIONING ERROR CHECKING CODES.)

paul niten
Newbie Poster
1 post since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

Simple, I will leave how to make a linked list to you, it's really simple.If you dont have any info on that look to http://www.google.com/ .

int main(int args,char **argv)
{

}


This is what the main funtion should look like if you want to accept commandline parameters.Then getting hold of the parameters is as easy as pie (or a 2 dimentional char array ;))

The int variable args holds the number of parameters passed to your program
The char array hold the actual parameters

Look here to see how to display all the parameters

for(int i=0;i<args;i++)
{
     cout<<"Arg No ["<<(i+1)<<"] = "<<argv[i];
}


That will show you all the parameters passed via the commandline.Also the first parameter (i.e argv[0] ) is always the full path to your exe.

Helps?

FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You