C and C++ Programming Resources

Problem here

General Discussion on any topic..

Problem here

Postby glenlove2002 » Sun Jan 08, 2006 6:42 am

Hey, how do u force a user to enter only letters from the keyboard in an Ansi C console Application? I'm trying to write a small program but it goes crazy when I enter any thing numeric, which I shouldn't do.
 
Me and Me makes Me.
User avatar
glenlove2002
 
Posts: 1
Joined: Sun Jan 08, 2006 6:37 am
Location: United Kingdom

Postby msaqib » Sat Jan 14, 2006 1:17 pm

Hello, wel if u can post the code in which u r facing difficulties.
As far as I understand below is the solution for ur problem.
Code: Select all
while((key=getch())!=ESC)
{
switch(getch()){
//case 1 to 10 do nothing
//case write the characters on the screen
}
}

To me this is the shortest solution to the problem above.
C and C++ Programming Tutorials & Source Code
http://mycplus.com
User avatar
msaqib
 
Posts: 74
Joined: Sun Feb 22, 2004 2:38 pm
Location: United Kingdom


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron