Results 1 to 9 of 9

Thread: Convert integer/long to a string???

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    Arrow

    I have made a function for displaying text basing the coordinates on a given XY point:
    Code:
    void xytext(int x, int y, char *text)
    {
        move_to(x,y); /*move graphics device to x,y */
        plots(text);     /*plots the text string */
    }
    This will plot the given text to a given point. This is intended for powerc(you can use another compiler) or any compiler that doesn't have the function outtextxy();

    Here is my problem: I would like to turn an integer so I can put it into a string, to display it using this function. I'm not good with strings, so can you tell me how I could add that string(converted int) to the end of another string(a phrase), so I can do something like this:

    "Mouse X = " + (Interger(say 77) to string)
    "Mouse X = " + "77"
    "Mouse X = 77"

    You get it? Please help me on this. It's EXTREMELY IMPORTANT!!!

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    PHP Code:
    char buf[40];
    itoa(numberbuf10); 
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    Thanks, Parksie!!!

    Now how would I add that to the end of a string? (add 2 strings into 1)

  4. #4
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    Use the "strcat" function.

    Code:
    .
    .
    .
    char buff[10] = "Hello ";
    char buff2[10] = "world!";
    
    strcat(buff, buff2);
    .
    .
    .

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Also, sprintf should help here:
    Code:
    char buf[100];
    
    sprintf(buf, "Pos: (%d, %d)", xpos, ypos);
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    OK, That works. Now, I try to switch into a mode using interrupts. This causes my function to not work. Any ideas??? Does anyone have a substitute for my function that will work?

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I think you need to restore the interrupt state after changing...not totally sure...it's just what I remembered from browsing that VBE documentation ages ago.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    You mean VESA? I was using those VBE modes. Can you figure out how to restore the interrupt states? I'll try as well. Thanks

  9. #9

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    Question

    Ok... Maybe the PowerC print functions aren't good enough. Does anyone know the source code for outtextxy(int x, int y, char *text); , or a similar function? This is higher priority than my thread's actual topic. Please help...

Posting Permissions

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



Click Here to Expand Forum to Full Width