Number, Letters and Space Only allowed.
Feb 5, 2011 at 9:11am UTC
hey guys.. i just want your help.. because i am making a program that has only numbers, letters, and space should be allowed.. i dont know the syntax for the space and for the numbers >.<
i already made this program but only characters and backspace allowed..
here is the code:
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
int main(){
char *letter;
char hold;
int ctr = 0;
char *holdLetter;
letter = (char *)malloc(sizeof (char ));
holdLetter = letter;
printf("Enter String Letter: " );
do
{
hold = getch();
if (isalpha(hold))
{
*holdLetter = hold;
printf("%c" , *holdLetter);
holdLetter++;
ctr++;
*holdLetter = 0;
}
else if (hold == 8 && ctr!= 0)
{
printf("\b \b" );
ctr--;
holdLetter--;
}
}while (hold !=13);
*holdLetter = 0;
free(holdLetter);
printf("\nLetters are : %s" , letter);
getch();
return 0;
}
any hints there sir??
can someone help me with space and number? T_T
Topic archived. No new replies allowed.