What is difference between const char * and char * const in C

preview_player
Показать описание
this video will explain popular quesion of C
difference between
const char * ptr;
char * const ptr;
Рекомендации по теме
Комментарии
Автор

Thank you for the clear explanation!
So:
"const char * ptr" means ptr can point to anywhere, but whatever place ptr points to, we cannot use ptr to change value
"char * const ptr1" means ptr1 can only point to one place, but we can change that place's value to whatever we like.

jinyang
Автор

const *ptr;//you can change address but cannot change the value stored on that address
char *const ptr;//you can change the value stored at particular address which pointer variable stored, but you cannot
change the address (or location )of the ptr stored in it...
???

Sahilbc-wjqk
Автор

Thanks for the video 😊😊 it was really helpful

knowingitintobeing
Автор

Thanks for the video, can you guide me which datatype i should use for a socket buffer, which can handle strings, special characters, and null chars. My socket input stream contains null chars which need to be included in the buffer. (means I cant ignore null chars neither want to get the stream terminated because of null char).

anisht
Автор

Please do C programming tutorials from the begining with basics.. I like your videos..

RavinduPrabuddha
Автор

what about
char const* const name;?
can't change whatever in the location name is pointing, and can't change name as well??

Muhammed.Abd.
Автор

For *const char *p*
All confusion lies in the line -

const char *p = &x;
printf ("the value which is pointed to by p : %c\n", *p);

The confusion is that how could the Output to the above 2 statements be :
X
and not the address of the variable X
because that's what is stored in the pointer, *p.

sayantaniguha
Автор

Please upload other technical concept in C
.. Your explanation was good really good here

rajkanyasaha
Автор

Thank you very much! I was having difficulty with this exact topic. Your explanations were clear and it was extra helpful to show the compiler errors generated for mis-use of the pointers.

jimsavarino
Автор

tks alot. very clear explanations!, keep up your work!

VineU
Автор

This is a very important concept in C and I am glad that you have efficiently and clearly given an explanation to it.
Thanks a lot.

sanketmachhindrapadwal
Автор

Good explanation with apt use of examples. Thanks !!

jahanwadia
Автор

Well explained, Thanks! Linux FTW! :)

metaldownm
Автор

sorry, your explanation is wrong about to explain const char *ptr;

dr.shabbirhassan