我编写了以下代码:
#include <sys/timerfd.h>
#include <ctime>
#include <inttypes.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
printf("Test_message");
int tfd;
uint64_t count;
tfd= timerfd_create(CLOCK_MONOTONIC,0);
itimerspec itimer;
itimer.it_interval={1,0};
itimer.it_value={1,0};
timerfd_settime(tfd,0,&itimer,NULL);
while(true)
{
read(tfd, &count, sizeof(count));
}
}
当我编译和链接时,我们没有输出到控制台。但我预计Test_message
将被打印。
最佳答案
- 运行程序。
- 不要忘记缓冲 - “测试消息”将是它们的,直到它被刷新。请参阅
fflush
关于c++ - 如果没有\n则不会打印消息,而使用\n则打印消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23590240/