How to compare string command line arguments in C?

c, command-line-arguments, pointers, string-comparison

Solution

That's not how you compare strings in C. Use `strcmp` or `strncmp`:

if (strcmp(argv1, HELP) == 0)

Include `string.h` to get access to those.

Problem

Sorry, I'm a rookie in C. What I am trying to do is just to print something if --help parameter is entered to the terminal like `./program --help`. So the code is this: ``` char *HELP = "--help"; char *argv1 = argv[1]; if (argv1 == HELP) { printf("argv[1] result isaa %s\n", argv[1]); } ``` So even if I use --help parameter it does not pass through the if condition. So what could be the reason behind that?

Original source