Pointer to Character Variables

char *cptr=“abc”;

The output of cptr is abc.
The output of *cptr is a.
The output of &cptr is some address.

Can you please explain how are these outputs being obtained?

@poojagera
Hello Pooja,
cptr is containing base/starting address of string “abc” i.e address of ‘a’ .
a) now when we print *cptr it means print value at address cptr and because value at address cptr is ‘a’ you will get ‘a’ as output.
b) when we print cptr then we will get abc as output i.e it will print all character before ‘\0’
c) &cptr will print adress of cptr

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like