I''m writing an app that is going to be command line. I am using Win32 console, how do I make it accept command line arguments?
Sand Hawk
----------------
-Earth is 98% full. Please delete anybody you can.
My Site
command line arguments
If you are writing a console app you will recognise..
int main(int argc,char *argv[])
argc is the counter of arguements you have sent, and argv is the array that contains them..
I think that the first
argv[0] = the full filepath of application
argv[1]... etc = arguements seperated by spaces
int main(int argc,char *argv[])
argc is the counter of arguements you have sent, and argv is the array that contains them..
I think that the first
argv[0] = the full filepath of application
argv[1]... etc = arguements seperated by spaces
You can accept command line arguments using argc and argv.
i.e.
i.e.
int main(int argc, char* argv[]){ //use argc to see how many arguments were passed if(argc < 2) std::cerr<<"Not enough arguments\n"; //now use the first argument, argv[0] is the app.exe std::string str = argv[1];...}
You can accept command line arguments using argc and argv.
i.e.
i.e.
int main(int argc, char* argv[]){ //use argc to see how many arguments were passed if(argc < 2) std::cerr<<"Not enough arguments\n"; //now use the first argument, argv[0] is the app.exe std::string str = argv[1];...}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement