Using memchr to search for a byte - C++ Data Type

C++ examples for Data Type:char array

Description

Using memchr to search for a byte

Demo Code

#include <iostream> 
#include <cstring> // memchr prototype 
using namespace std; 

int main() /* w  ww.  j  a v a 2s.c  o  m*/
{ 
   char s[] = "This is a string"; 

   cout << "s = " << s << "\n" << endl; 
   cout << "The remainder of s after character 'r' is found is \"" 
       << static_cast< char * >( memchr( s, 'r', 16 ) ) << '\"' << endl; 
}

Result


Related Tutorials