Help with outputting an integer

Discussion in 'Programming' started by davegibelli, Nov 21, 2007.

  1. davegibelli

    davegibelli New Member

    Joined:
    Nov 21, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    With the simple code below...

    char ptr[4]={0x00, 0x00 ,0x00, 0xff};

    printf("%u", *ptr);

    you would expect to get 255 BUT I get zero...why?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Why you are expecting 255. ptr is the address of the base location and * means value at that location and so it should be what you are getting.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice