Is there a datatype string in c++?How is the memory allocation?
Answer Posted / ganesh chincholkar
Yes true string is not a datatype in C++ but it is implemented through Standard Template Library. And the string class has dynamic memory allocation.
eg:-
string str;
cin>>str;
string str gets dynamically allocated storage and that storage size is not permanent and can be modifies later.
after:
what happens behind screen is actualy:
string str = new char[strlen(str) + 1];
when you take input of the string str its size is calculated and you get the desired meomry.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you remove an element from a set in c++?
What are advantages of using friend classes?
Can I run c program in turbo c++?
Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?
What is the basic structure of c++ program?
Explain the difference between c & c++?
Which is the best c++ compiler for beginners?
What are manipulators used for?
If there are two catch statements, one for base and one for derived, which should come first?
What is null and void pointer?
What's the order in which the local objects are destructed?
Is c or c++ more useful?
what is Member Functions in Classes?
What is a set in c++?
Write a program which uses Command Line Arguments