| | |
Character handling problem! (isdigit)
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 49
Reputation:
Solved Threads: 2
cpp Syntax (Toggle Plain Text)
void choiceSelect() { int choice; char exitconfirm[100]; printmenu(); cin >> choice; if (isdigit(choice)) { if (choice == 7) { cout << "Exiting program. Enter yes to confirm.\n"; cin.ignore(); cin.getline (exitconfirm, 100, '\n'); if (strcmp ("yes", exitconfirm) == 0) { exit (1); } else { choiceSelect(); } } while (choice != 7) { if (choice == 1) cout << "1"; else if (choice == 2) cout << "2"; else if (choice == 3) cout << "3"; else if (choice == 4) cout << "4"; else if (choice == 5) cout << "5"; else if (choice == 6) cout << "6"; else choiceSelect(); } } else { cout <<"error!!!"; cin.ignore(); choiceSelect(); } }
Hi, I need some help with my assignment yet again. This time, it's just a simple recursive loop that I can't get working.
I've done most parts but I can't figure out why the "isdigit" isn't working. I want the program to detect if the user inputs anything other than numbers.
If I understand correctly,
if (isdigit(choice))
if choice = numbers, it'll run the program since it's true. However, it doesn't, Instead it runs the else part.
Can anyone point me in the right direction. Appreciate the help
Last edited by dexter1984; Aug 27th, 2008 at 12:30 pm.
![]() |
Similar Threads
- Anagram Tester Program That I Just Can't Figure Out (Computer Science)
- Any Boolean Expression to Sum of Minterms (C++)
Other Threads in the C++ Forum
- Previous Thread: Calculator, Includes Sin, Cos, Tan And Sqaure Root!
- Next Thread: Visual c++
| Thread Tools | Search this Thread |
api array based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






