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
Who invented turbo c++?
What problems might the following macro bring to the application?
What is the full name of logo?
How new/delete differs from malloc()/free?
If I is an integer variable, which is faster ++i or i++?
What do you mean by “this” pointer?
Can we use this pointer inside static member function?
Difference between a copy constructor and an assignment operator.
What is operators in c++?
You run a shell on unix system. How would you tell which shell are you running?
What is the auto keyword good for in c++?
Which operator cannot overload?
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
Explain unexpected() function?
Why do you use the namespace feature?