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?

Answers were Sorted based on User's Feedback



Is there a datatype string in c++?How is the memory allocation? ..

Answer / nithin devang

There is no DataType called String in C++.
String can be created using character array and delimited by
null character i.e. '/0'.
like char name[]={'n','i','t','h','i','n','
','d','e','v','a','n','g','0'}
or
char name={"nithin devang"}//it will automaticall append
null char.
Null character is having value (ASCII) Zero. (0 character
dont have ascii value 0)
--
If you still wish to use the keyword string you may declare
a macro
#define String char[];

my answer surety %=98%
-------------------
Read Expert C programming, The deep C secrets by Peter Van
Der Linden

Is This Answer Correct ?    2 Yes 0 No

Is there a datatype string in c++?How is the memory allocation? ..

Answer / nithin devang

There is no DataType called String in C++.
String can be created using character array and delimited by
null character i.e. '/0'.
like char name[]={'n','i','t','h','i','n','
','d','e','v','a','n','g','0'}
or
char name={"nithin devang"}//it will automaticall append
null char.
Null character is having value (ASCII) Zero. (0 character
dont have ascii value 0)
--
If you still wish to use the keyword string you may declare
a macro
#define String char[];

my answer surety %=98%
-------------------
Read Expert C programming, The deep C secrets by Peter Van
Der Linden

Is This Answer Correct ?    0 Yes 0 No

Is there a datatype string in c++?How is the memory allocation? ..

Answer / 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

More C++ General Interview Questions

What are the storage qualifiers?

0 Answers  


Why use of template is better than a base class?

0 Answers  


What is the full form of c++?

0 Answers  


What do you mean by ‘void’ return type?

0 Answers  


What are the advantages of prototyping?

0 Answers  


Write a program to find the Fibonacci series recursively.

0 Answers   Huawei,


Why do we use using namespace std in c++?

0 Answers  


What is a hash function c++?

0 Answers  


What is the difference between a baller and a reference in C++?

0 Answers  


What do you mean by internal linking and external linking in c++?

1 Answers  


How do you traverse a btree in backward in-order?

0 Answers  


what are Access specifiers in C++ class? What are the types?

0 Answers  


Categories