This is my first post, so please forgive me if I haven't followed the guidelines correctly!
I am writing a C function which returns an integer and accepts a char* as an argument. The function is an if block to compare the text in the char* value (or should I say the location to which it points!) and set the integer to a value depending on the text value:
This isn't the actual function: I cannot post the actual function as it is part of a proprietary package I am writing!
int function_name(char* input)
if (input == "TextValue") outputNum = 0;
else if (input == "OtherValue") outputNum = 1;
else if (input == "OneMore") outputNum = 2;
else outputNum = 3;
The problem I am having is that whatever text value is passed in, the int is set to 3 (the else value), even if the char* is, say, "TextValue". When invoking the function, I do as:
function_name(input); where input is of type char*.
Am I missing something very basic or is there something else to it? I have thought about the strstr() function in string.h, but I would like to avoid that if, at all, possible.