Hi,
Whenever a user types ./a.out with the wrong number of arguments I want my program to output something like
Usage: ./a.out <-e/-d> <FIlename> <Value>
how can I do this?
Hi,
Whenever a user types ./a.out with the wrong number of arguments I want my program to output something like
Usage: ./a.out <-e/-d> <FIlename> <Value>
how can I do this?
You'll have to look at the arguments that main accepts:
int main( int argc, const char* argv[] )
{
if (argc != 4)// program name and 3 arguments
{
std::cout << "Usage: ./a.out <-e/-d> <FIlename> <Value>\n";
return 0;
}
//rest of the program
return 0;
}
If you want to learn how/why this works, you should read this
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.