I'll admit, I feel like an idiot. It's 3 in the morning and I refuse to go to bed until this is solved. So here's the dealio:

void doThisIGuess()
    int numb = getch();
    char numa = char(numb);

    int num = atoi(&numa);
    if (num != 0)
        cout << num;

    else cout << numa;

I know it's a bit roundabout, but I'm a simple guy and I don't want too much tough code all at once since this function is part of a pretty complex program. Or something. Anyhow, it should return the key you pressed (as long as it's an ASCII value, number or letter) and it does for the most part.... 'a' returns 'a', 'b' returns 'b', but for some reason, all of the numbers return doubles of themselves. For instance, '1' returns '11', '2' returns '22', etc. WTCPP?

6 Years
Discussion Span
Last Post by j6m8

O mighty C++ gods, how you taunt me. atoi(), I presume, doesn't get assigned to a variable like char() does -- that is, i = int(j) works, but i = atoi(&j) just modifies j. Well, I guess that's that. If anyone else is having that problem, here's your solution.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.