开发者

can scanf be terminated on pressing some specific key other than enter

开发者 https://www.devze.com 2022-12-20 04:57 出处:网络
I have a situation here i am taking input fro开发者_StackOverflowm user using scanfcan I terminate the scanf as soon as user presses the # key

I have a situation here

i am taking input fro开发者_StackOverflowm user

using scanf can I terminate the scanf as soon as user presses the # key

please enlighten me on this


No, scanf() (or rather stdin, by default) is line-oriented so it needs to read a full line.

Look into ncurses or similar libraries for "raw" key-by-key input.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号