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
What is unary operator? List out the different operators involved in the unary operator.
Why namespace is used in c++?
Is c++ used anymore?
Is c++ fully object oriented?
Is it legal in c++ to overload operator++ so that it decrements a value in your class?
What are c++ files?
Which format specifier is used for printing a pointer value?
Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).
What is a buffer c++?
Describe private, protected and public – the differences and give examples.
Is c# written in c++?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
What are vtable and vptr?
What is the use of vtable?
You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()