Using strtok : string function « Data Types « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

#include <cstring>
using std::strtok;                        

int main()
{
   char sentence[] = "a c d e f g e a c d e y gb ";
   char *tokenPtr;

   tokenPtr = strtok( sentence, " " );

   while ( tokenPtr != NULL ) 
   {
      cout << tokenPtr << '\n';
      tokenPtr = strtok( NULL, " " );
   }

   return 0;
}
a
c
d
e
f
g
e
a
c
d
e
y
gb








2.24.string function
2.24.1.Using strcpy()
2.24.2.Using strncpy()
2.24.3.strcpy, strlen, strcmp, strcat
2.24.4.Convert a string to uppercase.
2.24.5.Using strcat and strncat.
2.24.6.Using strcmp and strncmp
2.24.7.Using strtok
2.24.8.Using strlen