Thread: converting ints to chars

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    54

    converting ints to chars

    I have 255 integer values ranging from 0 to 255

    i have char message[255]

    i want to convert each of these integers into there ascii letter and then put them into the message

    eg:

    message[0] = ascii version of first int
    message[1] = ascii version of second int

    and so on

    any help would be greatly appriciated

  2. #2
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Not all ASCII characters have a symbol.
    Code:
    #include <stdio.h>
    int main()
    {
        int i;
        for(i=0; i<256; i++) putchar(i);
        getchar();
    }

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    54
    sweet,

    thanks for the help

  4. #4
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Quote Originally Posted by mike_g View Post
    Not all ASCII characters have a symbol.
    Code:
    #include <stdio.h>
    int main()
    {
        int i;
        for(i=0; i<256; i++) putchar(i);
        getchar();
    }
    ASCII is only defined from 0 to 127.

    I think there's no real standard for number from 128 to 255. It will print different symbol depending on the computer you are using.



    i want to convert each of these integers into there ascii letter and then put them into the message
    In fact, you aren't converting anything. Someone could explain better than me, but ASCII is a just a convention who says, for example, that if you have the binary pattern "0100000" and want it expressed as a character on the screen, than it must print the character "A". And so on.

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    151
    STill insist on putting chars into the message ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. joining two chars together and converting to INT
    By tehprince in forum C++ Programming
    Replies: 5
    Last Post: 12-21-2007, 02:08 PM
  2. Converting Chars to Ints
    By sycorax in forum C++ Programming
    Replies: 2
    Last Post: 09-06-2005, 10:40 PM
  3. atoi not converting chars to ints?
    By C++Child in forum C++ Programming
    Replies: 13
    Last Post: 10-08-2004, 03:59 PM
  4. converting chars to uppercase/lowercase
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 05-08-2002, 07:55 PM
  5. converting chars to ints
    By nebie in forum C++ Programming
    Replies: 6
    Last Post: 09-01-2001, 11:33 AM