Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正如标题所述。我有gets(buffer)无限while(1)循环,它停止gets(buffer)并无限等待。我只想gets(buffer)等待 3 秒,以便从 STDIN 输入,然后当缓冲区中没有字符串时,再将控制权传递给 while,依此类推。 C是语言 提前谢谢!
gets(buffer)
while(1)
标准gets()函数没有超时功能。在 C 中实现 I/O 操作超时的规范方法是使用select()函数.
gets()
select()