65

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!

iaacp
  • 4,655
  • 12
  • 34
  • 39

2 Answers2

118
if (strstr(request, "favicon") != NULL) {
    // contains
}
22
strstr(request, "favicon") != NULL
Fred Foo
  • 355,277
  • 75
  • 744
  • 836