Welcome Guest.


How can I get the location of a specific string?

Asked by: Raymond Scott 156 views IT August 12, 2019

For example: string 1: AGAHGDHGAHDGAG, string 2: HGA, how to get the part before string 2?

1 Answers

  1. +3Votes  

    What language? For C/C++, simply use strstr, prototype

    char *strstr(const char *s1, const char *s2);                /* C only */


    const char *strstr(const char *s1, const char *s2);          // C++ only

    find the first one for char *s="AGAHGDHGAHDGAG";

    , you can use


    and later, there can be


    Brenda Scott- August 12, 2019 |