Strings
- Which method do we use to append more than one character at a time?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
data
- What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string s ("Interview Mania");
cout << s.capacity();
cout << s.max_size();
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We are printing the capacity and max size of the string.
- What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string s ("Interview Mania");
for (size_t k = 0; k < s.length();)
{
cout << s.at(k-1);
}
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::at: __n (which is 18446744073709551615) >= this->size() (which is 15)
timeout: the monitored command dumped core
sh: line 1: 24994 Aborted timeout 10s main
- What is the header file for the string class?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
#include<string>
- Which is used to return the number of characters in the string?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Both will return the number of characters that conform to the string’s content.