Thread: HTML2ASCII Conversion

  1. #16
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    atoi? shouldnt i use itoa? im trying to use it like this:

    Code:
    default: {
                    char buff[2] = { '\0' };
                    itoa(data, buff, 3);
                    
                    strcat(dest, buff);
                    printf("Buffer = %s", buff);
                }
    its doesnt work out right, its gives me numbers as output and then crashes. can you show me how its done(and what the hell a radix is)?

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by mart_man00
    atoi? shouldnt i use itoa? im trying to use it like this:
    Actually I was thinking of atoi, I just had a brain lapse and forgot what it did.

    Try this instead:
    Code:
    void fun( int x )
    {
        char buf[BUFSIZ]={0};
        char buf2[BUFSIZ]={0};
    
        sprintf( buf2, "%s", x );
        strcat( buf, buf2 );
    
        printf("Buffer = '%s'.\n", buf );
    }
    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    the sprintf part of that code makes it crash. when i change it to printf i just get nothing("Buffer = ''."). are you trying to show me how strcat works? i already now that it takes the second string and add it to the end of the first, i just dont get why i cant get away with a character for the second string part. its just a array of one.

    i could do it other way like manual adding it in myslef, but i dont see why i have to.

  4. #19
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You cannot use an "array of one" as a string. A string by definition is a character or series of characters, terminated with a null zero. Thus, a single character, unless it itself is null, is not a string.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Header File Question(s)
    By AQWst in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2004, 11:31 PM
  4. Do I have a scanf problem?
    By AQWst in forum C Programming
    Replies: 2
    Last Post: 11-26-2004, 06:18 PM
  5. Creation of Menu problem
    By AQWst in forum C Programming
    Replies: 8
    Last Post: 11-24-2004, 09:44 PM