ExamVeda
Login
Home
Arrays and Strings in C plus plus
?

What will be the output of the following C++ code?
#include <iostream>  
#include <cstring>
#include <string>
using namespace std;
int main () 
{
    string str ("Steve jobs");
    char * cstr = new char [str.length() + 1];
    strcpy (cstr, str.c_str());
    char * p = strtok (cstr," ");
    while (p != 0)
    {
        cout << p << '\n';
        p = strtok(NULL," ");
    }
    delete[] cstr;
    return 0;
}

Answer & Solution
Correct Answer: Option C
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.