Hi,
The following build-in function (acceptNumber, acceptAlpha) are used to get the
input from the user. The special in that function is it only accepts
number/char.
#include <stdio.h>
#include <conio.h>
int main()
{
int acceptNumber();
char* accptAlpha();
int number;
printf("Enter the Number ");
number = acceptNumber();
printf("\n The Input Number is %d ", number);
}
int acceptNumber()
{
char ch,number=0;
do
{
ch = getch();
if(ch >= '0' && ch <= '9')
{
number = (number * 10) + (ch - 48);
putchar(ch);
}
}
while(ch != 13);
return number;
}
char* accptAlpha()
{
char alpha[100],ch;
int index = 0;
do
{
ch = getch();
if((ch >= 'a' && ch <='z') || (ch >='A' && ch <='Z'))
{
alpha[index++] = ch;
putchar(ch);
}
}
while(ch != 13);
alpha[index] = '\0';
}
~vishnu~
Meet people who discuss and share your passions. Go to
http://in.promos.yahoo.com/groups/bestofyahoo/
[Non-text portions of this message have been removed]