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
How the keyword struct is different from the keyword class in c++?
What is array in c++ example?
Difference between a copy constructor and an assignment operator.
Define the operators that can be used with a pointer.
How would you find out if a linked-list is a cycle or not?
Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.
What is the v-ptr?
Why do we use the using declaration?
Refer to a name of class or function that is defined within a namespace?
Why are pointers used?
What is meant by const_cast?
List the issue that the auto_ptr object handles?
What are member functions used in c++?
What is low level language in simple words?
What is runtime polymorphism in c++?