What is the difference between Char a[ ]=”string” and char
*a=”String”
Answer Posted / sushant mahajan
Ohk... dudes I think that 'C' in Char a[] is a typo. The only difference I can see is this:
char *a="string";
printf("%d", sizeof(a));
/*will print 2 or 4, whatever is the memory assigned to a pointer*/
char a[]="string";
printf("%d", sizeof(a));
/*will print 7 - 1 byte for each character+1 byte for the '\0' */
So basically its a memory thing :D
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is bubble sort c++?
Explain about vectors in c ++?
What is c++ redistributable?
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
Who calls main function?
What is the arrow operator in c++?
How does code-bloating occur in c++?
Is it possible to provide special behavior for one instance of a template but not for other instances?
What do you mean by enumerated data type?
What is the use of setfill in c++?
Do class declarations end with a semicolon? Do class method definitions?
Explain the use of this pointer?
Explain deep copy and a shallow copy?
Can you explicitly call a destructor on a local variable?
Give 10 points of differences between C & C++.