You have two problems with that code: The first is that 'add'
is a multi-character literal, and not a string. A string would use double-quotes like "add"
.
The second problem is that you can’t use equality comparison to compare string, as that will compare the pointers and not the contents of the strings. To compare strings you need to use strcmp
.
if (strcmp(input, "add") == 0) { ... }
solved String comparision in if statement generates some warnings