i am preparing project,in which i want to perform operation like user can only enter number 0 to 9 and can't enter alphabet or special symbol...for i have try many code but can't perform.... any one help me?
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Then check every character to be between 0 and 9, if not - don't accept this character.
If your app is a GUI one then the best way is to handle WM_CHAR message
i m not working in GUI. isdigit() do not work.
int ch;
do
{
cout<<enter choice;
cout<<1
cout<<2
cout<<3
cin>> ch
int c=isdigit(ch)
if(c!=0)
{
switch(ch)
{
case 1:cout<<"one";break
case 2:cout<<"two";break
case 3:exit;
}
else
cout<<"Enter only digit";
}
}while(!(ch==3));
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
if i include <ctype.h> it will give error "Function iswdigit() should have prototype" so i delete <ctype.h> and include <wchar.h> file but it also gives 2 error "Unable to open include file 'WCHAR.H'" and second error "Function iswdigit() should have prototype"
Last edited by CSharpque; February 23rd, 2012 at 11:12 PM.
Bookmarks