Home » C++ Programming » Strings » Question
  1. What is the output of this program?
     #include <iostream>  
    #include <cstring>
    #include <string>
    using namespace std;
    int main ()
    {
    string s ("Manjesh Ojha");
    char * cstr = new char [s.length() + 1];
    strcpy (cstr, s.c_str());
    char * p = strtok (cstr," ");
    while (p != 0)
    {
    cout << p << '\n';
    p = strtok(NULL," ");
    }
    delete[] cstr;
    return 0;
    }
    1. Manjesh
    2. Ojha
    3. Manjesh
      Ojha
    4. Ojha
      Manjesh
    5. None of these
Correct Option: C

In this program, We are breaking up the strings into the form of tokens.



Your comments will be displayed only after manual approval.