Command Line Parameter

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 1
Reputation: paul niten is an unknown quantity at this point 
Solved Threads: 0
paul niten paul niten is offline Offline
Newbie Poster

Command Line Parameter

 
0
  #1
Sep 10th, 2004
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.)
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: Command Line Parameter

 
0
  #2
Sep 10th, 2004
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/.

  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
  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?
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC