ASCII to string

This is a discussion on ASCII to string within the C++ Programming forums, part of the General Programming Boards category; Hey guys i am trying to convert mutiple ascii numbers to a single string. I can do this with one ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    3

    ASCII to string

    Hey guys i am trying to convert mutiple ascii numbers to a single string. I can do this with one but not two this is what i tried but this didn't work.
    Code:
    int y = 65;
    string word;
    int z = 66;
    word = int(y), int(z);
    cout << word;
    I'm really stuck on this one, thanks in advance.

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    88
    I think this is what you're trying to do...

    Code:
    #include <sstream>
    //...
    int num1 = 65;
    int num2 = 15;
    ostringstream oss;
    oss <<num1 <<num2;
    //Now, oss.str() gives us our string
    cout <<oss.str()

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    3
    Sweet I got it to work. Thank you very much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 07:02 AM
  2. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  3. string to ASCII and back...
    By skora in forum C Programming
    Replies: 3
    Last Post: 11-23-2003, 10:59 PM
  4. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  5. converting a string to it equivalent ascii value
    By pauljhot in forum C Programming
    Replies: 12
    Last Post: 02-16-2002, 02:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21