What is the difference between Char a[ ]=”string” and char
*a=”String”
Answer Posted / prasant nayak
differences are as follows
1.
Char a[]="string"; //invalid, coz--its not 'Char' but
its 'char' , i.e its syntaticaly incorrect
char *a="string";//it correct
2.
char a[]="string";
above 'a' is an array of characters , where we can change
the string, its not a constant.
i.e we can do a[3] = 'Z';
char *a = "string";
above 'a' is a string constant where we can't change the
string i.e we can't do a[3] = 'Z';
| Is This Answer Correct ? | 42 Yes | 6 No |
Post New Answer View All Answers
Why c++ is the best language?
When does a name clash occur in c++?
Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()
What is the benefit of encapsulation?
Is facebook written in c++?
Explain overriding.
Why is c++ still used?
Can you please explain the difference between using macro and inline functions?
Should the member functions which are made public in the base class be hidden?
why is iostream::eof inside a loop condition considered wrong?
What is a tree in c++?
How would you implement a substr() function that extracts a sub string from a given string?
How is objective c different from c++?
Write a Program to find the largest of 4 no using macros.
Which programming language is best?