Answers for "how to check if a string is a substring of another c"

C
0

check if string contains substring c

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

const char *tmp = "This string literal is arbitrary";

int main(int argc, char *argv[]){
    char *ret;

    ret = strstr(tmp, "literal");
    if (ret)
        printf("found substring at address %pn", ret);
    else
        printf("no substring found!n");

    exit(EXIT_SUCCESS);
}
Posted by: Guest on October-07-2021

Code answers related to "how to check if a string is a substring of another c"

Code answers related to "C"

Browse Popular Code Answers by Language