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
Describe linkages and types of linkages?
What are references in c++? What is a local reference?
What is the basic structure of a c++ program?
Explain one-definition rule (odr).
What is doubly linked list in c++?
What does floor mean in c++?
What is an iterator?
What is a linked list in c++?
Explain the properties and principles of oop.
How to declare a function pointer?
What is the difference between new() and malloc()?
Show the declaration for a static function pointer.
How is modularity introduced in C++?
Describe the syntax of single inheritance in C++?
What is one dimensional array in c++?