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 unary operator? List out the different operators involved in the unary operator.

994


Why namespace is used in c++?

1064


Is c++ used anymore?

1088


Is c++ fully object oriented?

966


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

1047


What are c++ files?

1139


Which format specifier is used for printing a pointer value?

1051


Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

995


What is a buffer c++?

1058


Describe private, protected and public – the differences and give examples.

1191


Is c# written in c++?

980


Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?

1259


What are vtable and vptr?

1140


What is the use of vtable?

1146


You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()

1157