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
Difference between overloading vs. Overriding
What is lambda in c++?
Why is c++ still popular?
What is size_type?
What is c++ code?
What are put and get pointers?
If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?
What are the advantages of prototyping?
What is java and c++?
Is there any function that can skip certain number of characters present in the input stream?
What does ctime() do?
What c++ library is string in?
Define friend function.
Explain the extern storage classes in c++.
How do you declare A pointer to a function which receives nothing and returns nothing