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
Which function cannot be overloaded c++?
Can you Mention some Application of C/C++?
What character terminates all character array strings a) b) . c) END
What is the difference between global int and static int declaration?
What happens if a pointer is deleted twice?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
What are the various access specifiers in c++?
Explain function overloading
What is a static element?
Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.
What are the advantages of pointers?
What are static and dynamic type checking?
How can you create a virtual copy constructor?
What is the difference between set and map in c++?
What is singleton pattern in c++?