What is the difference between Char a[ ]=”string” and char
*a=”String”
Answer Posted / anshul
I guess the main difference for which interviewer was looking for it that name of the array is constant pointer and character pointer is not. So, if
char a1[]="string";
char *a2="string";
a2=a1;//Compiles and works perfectly
a1=a2;//Error caught at compile time
This is a famous example and is available in many C books.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is stoi in c++?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
What are maps in c++?
write a porgram in c++ that reads an integer and print the biggest digit in the number
Explain how a pointer to function can be declared in C++?
Can we define a constructor as virtual in c++?
List the merits and demerits of declaring a nested class in C++?
What is the meaning of c++?
How does class accomplish data hiding in c++?
which of the following is not an secondary constant a) array b) real c) union
Differentiate between a constructor and a destructor in c++.
How the programmer of a class should decide whether to declare member function or a friend function?
When should overload new operator on a global basis or a class basis?
Is java made in c++?
what are the decision making statements in C++? Explain if statement with an example?