sleep() delays output until end

> **Possible Duplicate:** > [Why does printf not flush after the call unless a newline is in the format string? (in C)](https://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-string) I'm using the sleep() function in C, and am running into a problem: I wasn't sure that this was the problem so I boiled the entire code down to this: int main() { printf("1"); sleep(3); printf("2"); return 0; } What I thought this should produce is 1 .. wait for 3 seconds .. 2. Instead the program waits for 3 seconds and then prints 12. Is there any way to use the sleep function so that I get the first output? Thanks
As I mention below, I was unaware that this was the cause of the problem.

以上就是sleep() delays output until end的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏