devxlogo

Filtering Input in scanf()

Filtering Input in scanf()

You can force scanf() to read only specific characters from the input source while ignoring all the rest. Alternatively, you can force scanf() to read all input characters except the ones specified in a search set. Suppose you want to read only letters but suppress numbers, punctuation signs, commas etc. For this purpose, use the following search set:

 char s[12]={0};// read chars in the range a-z A-Zfscanf(stdin,

devx-admin

Share the Post: