EmbLogic's Blog

pointers

what does this declaration means: char *ptr=”hello”; ??

3 Responses to pointers

  1. 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);

  2. Abhishek says:

    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’

  3. kpeswani says:

    here ptr gos to read only memory of stack . one can access it but cannot modify it

Leave a Reply to Hitesh Dhanwani Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>