Is there a datatype string in c++?How is the memory allocation?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.
Explain static and dynamic memory allocation with an example each.
What is the difference between cin.read() and cin.getline()?
What is static function? Explain with an example
How to implement is-a and has-a class relationships?
Implement strcmp
What is a rooted hierarchy?
What is microsoft c++ redistributable 2013?
What is std namespace in c++?
What is the difference between const and constexpr?
Describe functional overloading?
What does floor mean in c++?