Programming & Design
Question:
Difference between const *char p and char const *p;?
?
2011-11-10 20:47:51 UTC
Difference between const *char p and char const *p;
Three answers:
santanu bera
2011-11-12 22:05:55 UTC
1]char const *p;---------
Here string is always constant but pointer is not constant. For example--------
char const *s="Hello";
*s='M'; /*This will never work*/
s="Bye"; /*This will work fine*/
2]const *char p;
Here pointer is fixed But string is not fixed. for example----
const *char p="Santanu";
*p="Bera"; /*This will work fine*/
p="Bera"; /*Never works*/
sumit m
2011-11-11 07:24:31 UTC
char const *p; is legal way to declare
Techwing
2011-11-11 05:18:33 UTC
The second is legal, the first is not.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...