Need help in C ( Detect char) 03-16-2013, 07:18 PM
#1
-------------------------
(This post was last modified: 06-05-2019, 06:25 PM by chemicalrage.)
| Need help in C ( Detect char) filter_list | |
char ch;
//...
scanf(" %c", &ch);
if(ch == '1') {
//...![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)
int rc;
rc = scanf("%d", &ch);
if(rc > 0) {
//success
}Quote:On success, the function returns the number of items of the argument list successfully filled. This count can match the expected number of items or be less (even zero) due to a matching failure, a reading error, or the reach of the end-of-file.
If a reading error happens or the end-of-file is reached while reading, the proper indicator is set (feof or ferror). And, if either happens before any data could be successfully read, EOF is returned.
If an encoding error happens interpreting wide characters, the function sets errno to EILSEQ.
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)