Strcmp being dumb...
That was a stupid title, but it's what's happening...I think.
I'm trying to get the first argument after the program name (argv[1]) and see if it is "mute" or "unmute."
Here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{
if(argc == 0)
{
cout << "No args!";
}
else
{
if(strcmp("unmute", argv[1]) != 0)
{
cout << "Requested operation: unmute\n";
cout << "argv[1] reads: " << argv[1];
}
else if(strcmp("mute", argv[1]) != 0)
{
cout << "Requested operation: mute\n";
cout << "argv[1] reads: " << argv[1];
}
else
cout << "ERROR";
}
return(0);
}
|
For some reason, no matter what I type, this is my output:
1 2 3 4 5 6 7 8 9
|
I:\system\debug> system mute
Requested operation: unmute
argv[1] reads: mute
I:\system\debug> system unmute
Requested operation: unmute
argv[1] reads: unmute
I:\system\debug> system wtf
Requested operation: unmute
argv[1] reads: wtf
|
Anyone have any ideas?
Thanks
strcmp() returns 0 if the two values match.
Leave it to me to flip the values :'(
Thanks a lot firedraco!
Topic archived. No new replies allowed.