Data conversion

This is a discussion on Data conversion within the Windows Programming forums, part of the Platform Specific Boards category; In VC6++ How can I convert a long int to a CString Example: convert i to string and concate long ...

  1. #1
    abu
    abu is offline
    Registered User
    Join Date
    Mar 2003
    Posts
    11

    Data conversion

    In VC6++
    How can I convert a long int to a CString
    Example: convert i to string and concate
    long int i=12345;
    CString result="simple question"+i.ToString()
    string result is simple question 12345
    Thanks so much!!!
    The Beginner

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    you must remember the stantart ansi c... functions like ltoa() and strcat().
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    In C++:
    Code:
    #include <sstream>
    
    std::stringstream Stream;
    int i = 12345;
    Stream << "Simple question " << i << std::endl;
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    Haha, gotta love C#'s ToString() function... which can be used on almost anything.

    Devil Panther and Magos are right though... but since this is in the Windows Programming forum, I'll say that you can also use wsprintf().
    Last edited by BMJ; 09-03-2004 at 12:51 PM.

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,671
    CString has it built-in
    Code:
    int i = 12345;
    CString result;
    result.Format("simple question %d", i);
    gg

  6. #6
    abu
    abu is offline
    Registered User
    Join Date
    Mar 2003
    Posts
    11
    Thanks for your helps.
    I found the answer!!!
    The Beginner

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. data structure design for data aggregation
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 05-20-2008, 06:43 AM
  2. conversion from double to float - loss of data
    By diyteam in forum C++ Programming
    Replies: 20
    Last Post: 03-04-2008, 01:59 AM
  3. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 08:09 PM
  4. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 10:31 PM
  5. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM

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