i want to know that what is the actual difference b/w the
character array & character pointer.
One is an array, and the other is a pointer. What more
difference do you want?
then how u will get the addrees of a char array[]
By taking its address, using the & operator.
char str[]="be silent like u"
This defines an array, initialized with the characters in the
string literal.
char *p1="be eloquent r u"
This defines both a pointer and an (unnamed) array---a string
literal is an unnamed unmodifiable array. The pointer is
initialized with the address of the first character in the
unnamed array.
Note that this is not really correct C++. It's supported for
historical reasons, but you really should write:
char const* p1 = "be eloquent r u" ;
Here, there is the same implicit conversion as in the previous
initialization: an array (str) is implicitly converted to the
address of its first member.
but printing the p2 will give me the str
That's because of a long standing tradition that functions
(most, anyway) receiving a pointer to a char will treat it as
the address of the first element of an array of char, and will
process all of the following elements as well, up to but not
including a final '\0'.
In practice, the case almost never comes up in C++, because we
rarely if ever declare arrays of char, nor use pointer to char.