Can someone tell me why this doesn't work?
just a simple getinput function that for some reason doesn't work :confused: it just returns empty, can anyone help me out?
Code:
string getInput(string data, int limit, bool hidden) {
int ch, i = 0;
do{
ch = getch();
ch = tolower(ch);
if (ch == 8) {
//TODO: user hit backspace
} else if (isalnum((char)ch) && i <= limit && ch != 13) {
data += (char)ch;
if (!hidden) {
cout << (char)ch;
} else {
cout << "*";
}
i++;
} else if (i <= limit && ch != 13) {
Beep(350, 75);
}
} while (ch != 13);
return data;
}