Results 1 to 3 of 3

Thread: int in char*

Hybrid View

  1. #1
    Guest

    int in char*

    Here's the thing, I'm writting a transport system which uses SLIP, and along side my payload I would like to send the length of the payload to correctly asembel the file on the otherside and other cool stuff, but I can't directly throw in a int of the default size 1024, since that causes al kinds of problems.

    So I figured that I could use atoi to turn it from ascii to int - which solves half the problem, is there a itoa function or how do we go about fetching the length of the array and putting it into the array?

    I figured that strlen(array) would give me the correct length and then what do we do to convert this into the chars '1' '0' '2' '4', of course we need to do this dynamically because of the possiblity of the last payload message not being 1024 chars. so I figure if we can do it like that, the problem will be solved and I can go about my life.

    thx in advance

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re: int in char*

    snprintf(temp_char_pointer, MAX_SIZE, "%ul", integer);

    isn't that the easiest itoa() function ?


  3. #3
    Guest

    Re: int in char*

    Yup, I already coded it using sprintf and atoi

Similar Threads

  1. char pointer not work right
    By Blaqb0x in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 03-13-2003, 09:00 PM
  2. String/Char Array commands ...
    By bafalouk in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 09-26-2002, 12:10 PM
  3. converting gf, special char problems
    By in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 06-03-2002, 07:55 AM
  4. I need help with char arrays in c
    By t048 in forum Linux - Software, Applications & Programming
    Replies: 6
    Last Post: 02-12-2002, 11:49 PM
  5. What is char-major-10-135?
    By Digital_Froggy in forum Linux - General Topics
    Replies: 2
    Last Post: 12-19-2001, 01:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •