Narrow the input: letter and space : Console Read Validation « Console « C / ANSI-C






Narrow the input: letter and space

  
#include <stdio.h>

int main(void)
{
  char str[80];

  printf("Enter letters and spaces\n");
  scanf("%[a-zA-Z ]", str);
  printf(str);

  return 0;
}


           
       








Related examples in the same category

1.Reading monetary amounts separated by commas and spaces
2.Reading types of strings from the keyboard
3.Exercising formatted input
4.Characters in the format control stringCharacters in the format control string
5.Read only a range of char
6.Read a certain length of string
7.Narrow down the input by setting scanf