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 are proxy objects in c++?
How does java differ from c and c++?
What does it mean to declare a member function as virtual?
Who made c++?
What do you mean by public protected and private in c++?
Is c++ fully object oriented?
Difference between pass by value and pass by reference?
Can we overload operator in c++?
Using a smart pointer can we iterate through a container?
Who created c++?
Is java the same as c++?
What is the last index number in an array of 100 characters a) 100 b) 99 c) 101
What are the characteristics of friend functions?
What is constructor c++?
What are friend classes?