Help

This is a discussion on Help within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to get a number from an edit box and multiply it but it, but some numbers when multiplyed ...

  1. #1
    Unregistered
    Guest

    Help

    I'm trying to get a number from an edit box and multiply it but it, but some numbers when multiplyed return letters, so far what people have suggested doesn't work so heres what i have tryied and the code thats returning the letters.

    char buffer[25];
    GetWindowText(ebox,buffer,25);
    int temp = atoi(buffer) * 2;
    itoa(temp,buffer,25);
    sprintf("%d",buffer);
    SetWindowText(ebox,buffer);

  2. #2
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,420
    remove the sprintf()

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    how about you use a better subject title than "help" and use code tags when you post?!
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  4. #4
    Unregistered
    Guest
    ok i'll use codetage and all that but do you have any ideas how to make this work right, with or without the sprintf it gives me the wrong vales like 6 * 2 = c

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    Code:
    char buffer[32];
    GetWindowText(hWnd, buffer, sizeof(buffer));
    int num = atoi(buffer) * 2;
    _snprintf(buffer, sizeof(buffer), "%d", num);
    SetWindowText(hWnd, buffer);
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  6. #6
    Unregistered
    Guest
    that works, now how would i make it muliply decimals like 2.5 *2 = 5? or 2.2 * 2 = 4.4? it doesn't do that right now.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21