944,084 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 7287
  • C++ RSS
Sep 10th, 2004
0

Command Line Parameter

Expand Post »
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.)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paul niten is offline Offline
1 posts
since Sep 2004
Sep 10th, 2004
0

Re: Command Line Parameter

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/.

C++ Syntax (Toggle Plain Text)
  1. int main(int args,char **argv)
  2. {
  3.  
  4. }

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
C++ Syntax (Toggle Plain Text)
  1.  
  2. for(int i=0;i<args;i++)
  3. {
  4. cout<<"Arg No ["<<(i+1)<<"] = "<<argv[i];
  5. }

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?
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Giving me hadaches
Next Thread in C++ Forum Timeline: asm in C





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC