Num to String? (atoi inverse)

This is a discussion on Num to String? (atoi inverse) within the C Programming forums, part of the General Programming Boards category; how can I do the inverse of atoi? here's the code Code: Num = atoi(PartC); // Convert to Number Num ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Location
    Rio de Janeiro, Brasil
    Posts
    48

    Lightbulb Num to String? (atoi inverse)

    how can I do the inverse of atoi? here's the code

    Code:
    Num = atoi(PartC);  // Convert to Number
    Num += 15;      //add 15
    strcat(String, ToString(Num));
    or something like that

    Code:
    Num = atoi(PartC);  // Convert to Number
    Num += 15;      //add 15
    PartC = ToString(Num);
    strcat(String, PartC);
    thanks!

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    sprintf
    Code:
    char buffer[10];
    int val = 20;
    sprintf(buffer,"%d",val);  /* Now buffer has "20" */
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

  4. #4
    Registered User
    Join Date
    Jun 2007
    Location
    Rio de Janeiro, Brasil
    Posts
    48
    thanks! work great!

  5. #5
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101
    atoi inverse
    You mean itoa.

    Sorry, my reply seems pretty redundant as sprintf works great for this. itoa() isn't in every stdlib though, just a warning.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 02:40 AM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 09:33 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM

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