4
I’m studying C, and now I’m trying to pass parameters. Well, although I think I did, it’s making a mistake when I try to use that variable...
I explain, the char "argument_value" that step on the command line, can be printed on the screen without the slightest problem, but if I use it inside an IF, it is as if it did not exist...
I need to compare the char "argument_value" to make decisions in the program!
What could I be doing wrong?
int main (int argument_count, char *argument_value[]) {
            printf("\n");
            printf("\nargument_value[0]  : %s", argument_value[0]);
            printf("\nargument_value[1]  :   %s", argument_value[1]);
            printf("\nargument_value[2]  :   %s", argument_value[2]);
            printf("\n");
            if      (argument_value[1] == "detailed"){printf("\n detalllll");}
            else if (argument_value[1] == "hexa")    {printf("\n hexaaaaaa");}
            else if (argument_value[1] == "bits")    {printf("\n bitsssss");}
            else                                     {printf("\n none...");}
}
This code always returns the parameters you pass on the command line, and "None..."
To compare strings in C, use the function
strcmp. Example here– Gomiero