Announcement

Collapse
No announcement yet.

converting int into a string

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • converting int into a string

    Hello, I'm trying to convert an integer into a string. I've found a few posts showing how to do the opposite, but don't see this. I'm guessing it's something easy. I've looked in the manual and have missed it too.

    Can somebody point it out?

    I'm hoping it's something like:

    itoa in C. Is it?

    Can you show an example?

    My int's will only range from 1-99, so converting to 01 to 99 is my goal.

    Barry

  • #2
    print(i) ;
    putnum(i) ;
    formats can also be sued with print, eg
    print([DEC2] i) ;

    if you want the number in a string and not just on the display use to(), eg
    var strx[20] ;
    to(strx);
    print([DEC2] i) ;
    Mark

    Comment


    • #3
      Hi Mark,

      No matter how I use the code that you wrote, I always get a value of 279. Here is my code:

      Code:
      var asdf[10];
      to(asdf);
      print([STR]newBuf);
      
      print(asdf);
      The value inside newBuf changes, but the output from this code is always 279. What am I doing wrong?

      Thank you

      Comment


      • #4
        try these

        Code:
            var i;
            i := 89;
            var asdf[10];
        
            print([DEC] i); // print integer i
        
            to(asdf);
              print([DEC] i); // print to asdf stream
        
            print("\n print string asdf: ");
            print([STR] asdf);

        Comment

        Working...
        X