How do I trap character inputs in C++?

This is just a portion of my program. My problem is that my program doesn't trap or block character inputs. I declare char opt='0' to go to main menu. If the user inputs a character the user must input again. How to trap it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
case '2':
    {
      if(y==1)
       {
         view();
       }
      else
      {
        system("cls");
        cout<<"\n\n\t\t------------------------------\n\n";
        cout<<"\t unable to view the record!!!!";
        cout<<"\n\n\t\t------------------------------\n\n";
        int v=1;
        while(v!=0&&!cin&&cin.fail()) //I used this for trapping a chararacter but it doesn't work.
        {
             cout<<"press 0 to go menu: ";
              cin.clear(); // clear the error
             // clear the input stream
              cin.ignore(100,'\n');
              cin>>v;
        }
       system("cls");
    }
 
   break;
}


this is the wrong output of my program when I input a character

press 0 to go menu:press 0 to go menu:
press 0 to go menu:press 0 to go menu:
press 0 to go menu:press 0 to go menu:
press 0 to go menu:press 0 to go menu:
press 0 to go menu:press 0 to go menu:
press 0 to go menu:press 0 to go menu:
press 0 to go menu:press 0 to go menu:
Topic archived. No new replies allowed.