Search code examples
c++strstr

strstr() function and "\r\n"


const char * strstr ( const char * str1, const char * str2 );
      char * strstr (       char * str1, const char * str2 );

Returns a pointer to the first occurrence of str2 in str1, or a null pointer if str2 is not part of str1

Lets say char* str2=new char(5000) is declared like this, and characters from a file are read into str2.

How does strstr work if str2 contains multiple '\r' or '\n' chars. Does it stop once it hits a '\n' or '\r' or does it continue? Also if it does continue, is there any way to stop the function at a certain point in str2?


Solution

  • It keeps going till the end of the string ('\0')