kathir resh wrote:
>   i am getting the correct output..in previous msg why they said its 
> crashing...
>   

Your compiler is allowing it to work, so it is not following the C 
standard correctly.

>   and say in detail about wh difference between char *s1="hello" and char s[ 
> ]="hello";
>   

"char *s1" is a pointer to a character, typically in some sort of static 
storage that you cannot modify. The idea is that the compiler can load 
up constants into a special place where you cannot change anything and 
it can store things more efficiently because it is static. "char s[]" 
defines an array, but because arrays are by definition multiple 
variables referenced by a single variable, the idea is that it is 
mutable storage.

Arrays can degrade into pointers, and you can grab a pointer to the 
first element of an array and use pointer arithmetic to navigate the 
array. The reverse is not true. Someone should have a link to the C FAQ 
that explains the "arrays and pointers" topic in extreme detail. I would 
google it but I have to run to the store and buy food here in a minute 
(pesky body needs more than just coding 16 hours a day).

-- 
John Gaughan

Reply via email to