Home > Software engineering >  How to search for a substring on a LPCSTR?
How to search for a substring on a LPCSTR?

Time:09-24

typedef _Null_terminated_ CONST CHAR *LPCSTR, *PCSTR;

// .....
LPCSTR foo = "hello world";

How do I search if foo contains hello?

CodePudding user response:

You can use strstr

LPCSTR foo = "hello world";
char * pch = strstr (foo,"hello");
  •  Tags:  
  • c
  • Related