Capturing command line characters to source code

Hey guys, how do I capture what the user enters into the command line into source code? In the main method, if I have

int main(int argc, char *argv[])

then how will I capture what the user types if he types this into the command line (after compiling):

./a.out textFile captureThis

where I want to capture "captureThis" and save it as a string or something.

Thank you!
All extra command line arguements supplied to your program are stored in the arguement vector or *argv[]. argc is called the arguement counter

When your program is executed, argv[0] is the name of the executable. So all extra arguements can be found from argv[1] to argv[argc - 1]
Last edited on
thank you!
Topic archived. No new replies allowed.