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

Describe linkages and types of linkages?

1046


What are references in c++? What is a local reference?

1106


What is the basic structure of a c++ program?

1196


Explain one-definition rule (odr).

1171


What is doubly linked list in c++?

1126


What does floor mean in c++?

1113


What is an iterator?

1241


What is a linked list in c++?

1106


Explain the properties and principles of oop.

1068


How to declare a function pointer?

1044


What is the difference between new() and malloc()?

2222


Show the declaration for a static function pointer.

1109


How is modularity introduced in C++?

1283


Describe the syntax of single inheritance in C++?

1120


What is one dimensional array in c++?

1177