tcp/ip实验需要在指定的时间查看结果,为了实验方便,做了一个定时器。使用方法是:
在命令行输入:timer
输入数字之后,计时相应秒数
输入m数字之后,计时相应分钟数(支持小数分钟数)
输入q退出。
时间到了之后会有3声蜂鸣,并显示Time is up!
OK,显示一个进度条会好用一些。
程序如下:
timer.cpp:
//g++ timer.cpp -o timer.exe -lboost_thread-mgw48-mt-1_56 -lboost_system-mgw48-1_56 -static
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <boost/thread.hpp>
#include <boost/progress.hpp>
#ifdef WIN32
#include <fstream>
#include <unistd.h>
#define TEMPNAME "WarningTemp~~~~~~.vbs"
#endif
using namespace std;
#define MAXLEN 100
int main()
{
printf("This is a simple timer.\n"
"Input sDigits to time the seconds you want.\n"
"Input mDigits to time the minutes you want.\n"
"For example input s9 to time 9 seconds and\n"