I have to pass four different text files in an argument in开发者_JS百科 c++ program. How do i pass??
int main(int argc, char ** argv) {
std::vector<std::string> args(argv, argv+argc);
for (size_t i = 1; i < args.size(); ++i) {
std::string const & aFileName = args[i];
// Do something with aFileName
}
}
I assume you mean on the command line. When main is defined as
int main(int argc, char *argv[])
argc is the count of arguments and argv contains them. The first arg in the array will be the name of the process and the others are the arguments passed to it.
加载中,请稍侯......
精彩评论