I have been recently learning C++, and I have started a small project, so that I do not get bored after school.
I am creating a program that takes command arguments, and throws a "USAGE" message if it isn't formatted correctly.
Here is my code:
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
if ( argc != 3 )
{
cout << "USAGE: " << argv[0] << " <-f/-c> <integer value>" << endl;
return 1;
}
else
{
if ( argv[1] == "-f" || argv[1] == "-F" )
{
}
else if ( argv[1] == "-c" || argv[1] == "-C" )
{
}
else
{
cout << "USAGE: " << argv[0] << " <-f/-c> <integer value>" << endl;
return 1;
}
}
return 0;
}
but for some reason, whatever I type in throws a "USAGE" message.
If anyone could tell me what I'm doing wrong, that would be fantastic!
Aucun commentaire:
Enregistrer un commentaire