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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a block in c++?

781


Distinguish between new and malloc and delete and free().

761


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

834


What are the methods of exporting a function from a dll?

845


What is a hashmap c++?

755


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

801


Which is best c++ or java?

844


Write about an iterator class?

814


Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

783


What is exception handling? Does c++ support exception handling?

788


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

793


How do you clear a map in c++?

816


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---

1856


What are friend classes? What are advantages of using friend classes?

844


Why do we use string in c++?

704