Read only a range of char : Console Read Validation « Console « C / ANSI-C

Read only a range of char

#include <stdio.h>

int main(void)
  int i;
  char str[80], str2[80];

  scanf("%d%[abcdefg]%s", &i, str, str2);
  printf("%d %s %s", i, str, str2);

  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 a certain length of string
6.Narrow down the input by setting scanf
7.Narrow the input: letter and space