I'm trying to pass arguments through main, which works fine, I then check to see if the passed in argument contains the correct format/value. However, even if I pass through the correct format it still shows that there is something wrong, here is the code:
int main(int argc, char* argv[]) {
/* Check if arguments are being passed through */
if(argc == 1){
cout << endl << "--- ERROR ---" << endl;
exit(0);
}
/* Check if the first argument contains the correct data */
string file_name = argv[1];
/* Handle operation */
string operation = argv[2];
if(operation != "-t" || operation != "-r")
{
cout << "Something is not right";
}
}
If I do: cout << operation;
then the result would be: -t
when passing -t through when I run the applications.
Could anyone suggest where I could be going wrong?
UPDATE:
I will pass in these arguments:
./main something.wav -t
I am expecting the if statement:
if(operation != "-t" || operation != "-r")
{
cout << "Something is not right";
}
To return negative since the value I have entered is -t