tags:

views:

37

answers:

2

Hi I have the following code:

#define INPUT_FILE "-i"

int main(int argc, char* argv[]) {
     ....
}

is there any way in C++ to compare between strings in argv[] and INPUT_FILE? I tried

strcmp(argv[1],INPUT_FILE)

It compiles but return false each time.

Thanks !

+3  A: 

strcmp returns 0 if there is a match.

codaddict
oh.. i feel stupid.. thanks!!
Mike
+1 for non-judgmental response, +1 on comment for public self-flagellation
Steve Townsend
+1  A: 

Have you tried printing argv[1]? Just to make sure you're comparing the right stuff...

But you also want to check the semantics of strcmp: It doesn't test if two strings are the same, it checks which one is bigger than the other. With 0 being "neither".

Daren Thomas
yes that was my problem.. thank you
Mike