Thread: Converting int to string

  1. #1
    Registered User ivandn's Avatar
    Join Date
    Oct 2001
    Posts
    49

    Question Converting int to string

    Hi,

    Is there a C function to convert from int to char* or do you have to do it manually with ASCII codes?

    Thanks
    Ivan

  2. #2
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284

    Post

    one way of tackling the problem
    #include <stdio.h>
    int main(void)
    {
    int x=3;
    char s[100];
    sprintf(s,"%d",x);
    puts(s);
    return 0;
    }


    int sprintf(char* s, const char* format, ...);
    Like fprintf, but output written into string s, which must be large enough to hold the output, rather than to a stream. Output is NUL-terminated. Returns length (excluding the terminating NUL).

  3. #3
    Registered User ivandn's Avatar
    Join Date
    Oct 2001
    Posts
    49
    Cool ... Thanks
    Ivan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  3. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-02-2003, 12:26 AM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM