Simple way to check if a string contains another string in C?

165,273
strstr(request, "favicon") != NULL
Share:
165,273
iaacp
Author by

iaacp

Updated on July 08, 2022

Comments

  • iaacp
    iaacp almost 2 years

    I'm pretty new to the language. Let's say I have a string from an HTTP request, such as

    char * request = "GET /favicon.ico HTTP/1.1";
    

    And I specifically want to know if favicon is in that request, perhaps with a boolean value. What is a relatively simple way to go about this? I know how to do it in Java, but I'm more lost with C.

    Thanks!