How the pointer holds a string in one address ? char *s = "hello"; char *p = s; printf( "%c" , s[0]); ANSWER = h | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How the pointer holds a string in one address ? char *s = "hello"; char *p = s; printf( "%c" , s[0]); ANSWER = h

Pointers

3rd Jan 2021, 10:02 AM
Gogul
Gogul - avatar
2 Answers
+ 5
The string is not held in one memory address, instead the pointer only holds the address to the 1st character of the string. Try running this char *s = "hello"; printf("%c", *s); It will output only the first char, meaning `s` is the address to only the first characer of the string
3rd Jan 2021, 10:11 AM
XXX
XXX - avatar
+ 1
Thank you very much
3rd Jan 2021, 10:14 AM
Gogul
Gogul - avatar