| | |
Command Line Parameter
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 1
Reputation:
Solved Threads: 0
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.)
(DON'T FORGET MENTIONING ERROR CHECKING CODES.)
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/.
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
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?
C++ Syntax (Toggle Plain Text)
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
C++ Syntax (Toggle Plain Text)
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?
![]() |
Similar Threads
- how to understand if msi is run by command line? (C#)
- Input with command line (C++)
- debugging with C++ command line arguements (C++)
- command line parameters part 2! (VB.NET)
- character input through command line problem (C)
- Preprocessor definitions on the command line (C++)
- Windows Main and Command Line Parameters (C)
- Using command line parameters (C++)
Other Threads in the C++ Forum
- Previous Thread: Giving me hadaches
- Next Thread: asm in C
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





