getline()函数的计时器 [英] timer for getline() function
本文介绍了getline()函数的计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hiii all
我想通过c ++中的getline()从命令行读取一个字符串。为此,我想添加一个5秒的计时器。如果没有读取字符串,则程序将终止。任何人都可以知道吗?我正在使用Centos 6.3
谢谢
hiii all
i want to read a string from commandline through getline() in c++. For that i want to add a timer of 5 sec. If no string read, then the program will terminate. can anybody know ?? I am using Centos 6.3
thanks
推荐答案
/ *等待5秒钟。 * /
闹钟(5);
/ * getline * /
/ *取消闹钟。 * /
闹钟(0);
/* Wait 5 seconds. */
alarm(5);
/* getline */
/* Cancel alarm. */
alarm(0);
你想做什么?等待5秒钟进行用户输入然后继续?
What are you trying to do? Wait 5 seconds for user input and then go ahead?
getline可以读取任何输入流,包括cin
getline can read from any input stream including cin
这篇关于getline()函数的计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文