int to string

This is a discussion on int to string within the C++ Programming forums, part of the General Programming Boards category; hey guys long time no see been making games, but im back now :P i need to figure out how ...

  1. #1
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178

    int to string

    hey guys long time no see been making games, but im back now :P

    i need to figure out how to convert an int to a string (dony ask why, long story) but i really need to figure it out
    ive tried stuff like

    int a =5;
    string b;

    b = (int)a;
    but no cigar

    thnx
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    use stringstream class
    Code:
    int n = 123;
    std::string s;
    std::stringstream str;
    str << n;
    s = str.str();

  3. #3
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    thnx alot
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

  5. #5
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    tnx and congrats to your 200th post
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    22
    Thank goodness the art of game development never requires one to convert an integer value to a string!!


  7. #7
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    i need it for my game to calculate FPS so yes thts why i asked :P
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 10:42 PM
  3. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM
  4. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM

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