Thread: Passing integers to escape values

  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Glasvegas, Scotland.
    Posts
    68

    Passing integers to escape values

    Hi Everyone,

    I'm trying to print out an ascending set of letters. The number depends on an input from the user so if the user said the number of inputs was 5 the program would print out:

    A B C D E.

    I thought i could do it like this:

    Code:
    for (x = 101;  x < input_from_user; x++)
    {
    printf("\%d", x);
    }
    Because \101 is ascii for A so i thought i could increment that in a for loop but i can't pass the value of 'x' to be escaped. It goes in ok but it prints out :

    Code:
    101 102 103 104 105
    Is there a way of doing this? Am i going about it the wrong way?

    Any help would be appreciated.
    Thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Use "%c".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Location
    Glasvegas, Scotland.
    Posts
    68
    ha fantastic! works now! Thanks Matsp!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Passing Values Question... (continue)
    By tinkerbell20 in forum C++ Programming
    Replies: 4
    Last Post: 06-29-2005, 01:51 AM
  2. Passing Values Question...
    By tinkerbell20 in forum C++ Programming
    Replies: 9
    Last Post: 06-27-2005, 11:33 AM
  3. Checking ascii values of char input
    By yank in forum C Programming
    Replies: 2
    Last Post: 04-29-2003, 07:49 AM
  4. Replies: 2
    Last Post: 11-22-2001, 12:22 PM
  5. Passing values from function to function
    By itld in forum C++ Programming
    Replies: 2
    Last Post: 10-24-2001, 07:28 AM