Int to char Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • noideanoclue
    New Member
    • Jul 2007
    • 5

    #1

    Int to char Array

    I was wondering how to take an integer and store it into a char array, if anyone could tell me that would be great.
  • JoeMac3313
    New Member
    • Jul 2007
    • 16

    #2
    Change the int into a string.

    Comment

    • prometheuzz
      Recognized Expert New Member
      • Apr 2007
      • 197

      #3
      Originally posted by JoeMac3313
      Change the int into a string.
      @OP:
      Yes, Joe is right. I'd just like to point you to the class that would be able to assist you on this. It's perhaps no surprise, but it's the java.lang.Strin g class:

      Especially look at the valueOf(...) and toCharArray() methods.

      Good luck.

      Comment

      • noideanoclue
        New Member
        • Jul 2007
        • 5

        #4
        I don't know if I'm just not getting it, or I asked the wrong question but what I want to do is take a pre-existing character array, and store a series of integers into it.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by noideanoclue
          I don't know if I'm just not getting it, or I asked the wrong question but what I want to do is take a pre-existing character array, and store a series of integers into it.
          You have to rephrase your question a bit then: given an int, do you want to store
          the individual characters of the decimal representation of that int in that array or
          do you want something else to happen? A pre-existing array of chars may be too
          small to hold the result ...

          kind regards,

          Jos

          Comment

          Working...