joplin-notes/joplin notion extension/Web Development/C_C++/Basics.md
2026-11-04 00:33:23 +05:30

670 B

Basics

  • const char vs char const char *p: This declares a pointer p that points to a constant character (immutable). It means that the data pointed to by p cannot be modified through p. However, p itself can be changed to point to a different memory location. So p[0]='H' is invalid as this constant say 'hello' is read only but if it is simply char *p then p[0]='H' is a valid operation   Wierd Case if const char *p is equivalent to 'hello' and we do char *q=p; and q[0]='H' then it is invalid bcz constant pointed by p is still read only and no matter if another pointer is pointing to it, that constant is still read only.