what does this declaration means: char *ptr=”hello”; ??
what does this declaration means: char *ptr=”hello”; ??
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
here ptr points to the first char of assigned string i.e address of ‘h’ .
add this to your program you yourself will understand:
printf(“address of pointer = %p \n address stored in the pointer = %p \n value at address stored in pointer = %c \n assigned string = %s \n”,&ptr,ptr,*ptr,ptr);
it is same as
char ptr[]=”hello”;
as in both case ptr will point to the address of first char of string i.e ‘h’
here ptr gos to read only memory of stack . one can access it but cannot modify it