Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the purpose of ios::basefield in the following statement?

1259


What can c++ be used for?

1101


What is the role of static keyword for a class member variable?

1074


Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).

1111


Can member functions be private?

1005


What are the uses of pointers?

1075


Can a new be used in place of old mallocq? If yes, why?

1096


How do I write a c++ program?

1118


What are the benefits of c++?

1056


What is the best c++ book?

1268


In what situations do you have to use initialization list rather than assignment in constructors?

1065


How do you print a string on the printer?

1040


Are c and c++ similar?

1054


What does it mean to declare a destructor as static?

1084


Why was c++ created?

1029