Thread: How do I increment printf hex characters?

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    2

    How do I increment printf hex characters?

    A simple question I think. I was wondering instead of having to type out the hex for each special character:

    Code:
    printf("\xA0 \xA1 \xA2 \xA3");
    I could just use a for loop and increment the hex part (A1, A2, A3, etc.) and list all of them. What would be the correct way of doing this, if possible?

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Code:
        int c;
      
        for (c = 0; c < 256; c++)
        {
          printf ("0x%02x = %c \n", c, c);
        }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    2
    Nice. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  3. Newb Help: Full Arrays and Functions
    By LycanGalen in forum C Programming
    Replies: 5
    Last Post: 01-31-2008, 08:35 PM
  4. Double to Int conversion warning
    By wiznant in forum C Programming
    Replies: 15
    Last Post: 09-19-2005, 09:25 PM
  5. Whats Wrong Whith This!?
    By SmokingMonkey in forum C++ Programming
    Replies: 8
    Last Post: 06-01-2003, 09:42 PM