Selective input using scanf. Possible to only read ascii 0x79 and 0x6e?

No , but you could use scanf to read a char.

No , but you could use scanf to read a char scanf("%c" , &yn ); after that you have to check whether it is y/n or illegal input. If ( yn == 'y' ) { ... }.

I have now implemented this method, many thanks! I just wondered if there was a shorter way of doing this. – user1083734 Dec 12 '11 at 8:29 @user1083734 perhaps if ( getchar() == 'y' ) {...} – stacker Dec 12 '11 at 14:03 thanks, i'll give it a go!

– user1083734 Dec 12 '11 at 14:45.

You can use the % conversion and do something like this: char yn2; if (scanf("%1yn", yn) == 1 && yn0 == 'y').

Thanks for your answer, I'm not sure I understand this % conversion though. Can you explain what is happening and why you don't include c but use yn? – user1083734 Dec 12 '11 at 8:31 the % conversion matches a non-empty string of characters from the specified set (yn in this case) – Hasturkun Dec 12 '11 at 9:30.

Better way should be to use the scanf scanset like: char c2; if( scanf("%1yn",c)==1 ) puts("yn"); else puts("not").

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions