How could I do something like:
to take a integer and char argument at the same time?Code:int main(int argv, char **argv)
Printable View
How could I do something like:
to take a integer and char argument at the same time?Code:int main(int argv, char **argv)
yep
Command line will accept anything. Your integers will be stored in a as a c-string. Something like this would work:
Note: I just typed this up in the post box... there's probably errors.Code:int main(int argc, char **argv)
{
std::vector<int> numargs;
for (int i = 0; i < argc; i++)
{
if (isdigit(argv[i][0])
numargs.push_back(atoi(argv[i]));
}
std::cout << "Number of numeric arguments: " << numargs.size()-1 << std::endl;
return 0;
}