Thread: printing short

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    201

    printing short

    I thought the following code was correct:

    Code:
    short s = ...;
    printf("%h\n", s);
    But this doesnt print anything with my compiler.
    when I do printf("%hd\n", s); it does work, but I really thought the 'd' could be omitted like with %u for instance. Is this correct?

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Quote Originally Posted by Laserve
    I thought the following code was correct:

    Code:
    short s = ...;
    printf("%h\n", s);
    It isn't.

    Quote Originally Posted by Laserve
    when I do printf("%hd\n", s); it does work, but I really thought the 'd' could be omitted like with %u for instance. Is this correct?
    No.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing Structures Inside Structures
    By Mellowz in forum C Programming
    Replies: 1
    Last Post: 01-13-2008, 03:55 AM
  2. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 04:48 PM
  3. Say what? - Weird error.
    By Blackroot in forum C++ Programming
    Replies: 6
    Last Post: 08-15-2006, 11:54 PM
  4. Help with mult-dim arrays and pointers to them
    By skybolt_1 in forum C Programming
    Replies: 11
    Last Post: 05-02-2003, 11:47 AM
  5. Color Variety
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 10-23-2002, 09:17 AM