C 语言中的 NCURSES 标准输入
由于某种原因 ncurses 不喜欢 stdin,我知道我可以使用 getstr() 代替,这就是我到目前为止所做的,
while (fgets(str, BUF, stdin) != NULL) {
printf("input something ");
}
我怎样才能得到替代方案到此循环的标准输入(也许使用 getstr())?
任何帮助将不胜感激。
谢谢
For some reason ncurses does not like stdin, I know I could use instead getstr(), here it is what I'm doing so far,
while (fgets(str, BUF, stdin) != NULL) {
printf("input something ");
}
How could I get an alternative to stdin for this loop (perhaps using getstr())?
Any help will be appreciate it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了使用 ncurses 捕获输入,我将根据您的需要使用 3 个函数之一:
getch() 用于字符,scanw() 用于格式化输入,最后是 getstr()
For capturing input using ncurses, I would use one of the 3 functions based upon your needs:
getch() for characters, scanw() for formatted input and finally getstr()
您可以使用 getstr() 从标准输入读取到缓冲区。查看curses HOWTO 获取示例。
You can use getstr() to read from stdin to a buffer. Check the curses HOWTO for examples.