How many maximum number of parameters does a string constructor can take?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
string str2="Steve jobs";
string str3="He founded apple";
str.append(str2);
str.append(str3, 6, 3);
str.append(str3.begin() + 6, str3.end());
str.append(5,0x2e);
cout << str << '\n';
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("I like to code in C");
unsigned sz = str.size();
str.resize (sz + 2, '+');
str.resize (14);
cout << str << '\n';
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string name ("Jobs");
string family ("Steve");
name += " Apple ";
name += family;
name += '\n';
cout << name;
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs founded the apple");
string str2 ("apple");
unsigned found = str.find(str2);
if (found != string :: npos)
cout << found << '\n';
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs");
cout << str.length();
return 0;
}
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;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Test string");
for ( string :: iterator it = str.begin(); it != 5; ++it)
cout << *it;
return 0;
}
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("Steve jobs");
cout << str.capacity() << "\n";
return 0;
}
15 videos|20 docs|13 tests
|
15 videos|20 docs|13 tests
|