How to check if a variable has a certain string in it? How to do it in an if condition? [duplicate]

So far I've got the following:

#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <string.h>

int main (void)
{
    printf("Loading BES Command Prompt...\n");
    sleep(5);
    printf("> ");
    char *input;
    scanf("%s", input);
    printf("\n");
    if (input == "exit")
    {
        printf("Terminating BEScmd.c...\n");
        sleep(2);
        return 100;
    }
}

However I need help because it won't use printf("Terminating BEScmd.c...\n"); and the compiler says it aborts with the Exit Code "0", not "100" which is what I want it to stop with.

Can you please help me here?



Read more here: https://stackoverflow.com/questions/67928259/how-to-check-if-a-variable-has-a-certain-string-in-it-how-to-do-it-in-an-if-con

Content Attribution

This content was originally published by BraveGamerTV at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: