While problem

Hello again, I'm having a little problem with a while statement.
Everything works perfectly fine, as long as the "begin" integer in "cin >> begin" is a number/digit, but as soon as a letter is inserted, the whole program starts acting as if someone was holding the refresh button, and I am unable to do anything with it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

//cut-out of the code I'm having problems with

    int begin;
    system("color E");
    do
    {
        cout << "Press 1. to start \nPress 2. for help \nPress 3. to exit\n";
        cin >> begin;
        if(isalpha(begin))
        {
            return 0;
        }
        system("cls");
    }while(begin != 1 && begin != 2 && begin != 3);
Last edited on
I have figured it out, instead of "int begin", I have used "char begin" and it works fine
Last edited on
Topic archived. No new replies allowed.