使用睡眠问题 [英] Problem using sleep

查看:60
本文介绍了使用睡眠问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用睡眠功能暂停几分钟,但这个睡眠功能总是先启动,无论它使用的程序是什么。喜欢

....


function1();

sleep(10);

function2();


睡觉首先执行。


如何解决这个问题,我试着在睡觉之前使用fflush()但是没有工作

解决方案




我正在使用睡眠功能暂停几分钟,但这个睡眠功能始终首先开始,无论它在程序中使用的是什么。喜欢

....


function1();

sleep(10);

function2();


睡觉首先执行。


如何解决这个问题,我试着在睡觉之前使用fflush()但是没有'



这些函数是否返回值?如果他们这样做你可以这样做:


function1( )-on succes返回1 else返回0

如果(function1())调用sleep();


Savage


< blockquote>没有任何功能不会返回任何值。但是为什么sleep()函数不遵循程序的顺序流程?



没有任何函数没有返回任何值。但是为什么sleep()函数不遵循程序的顺序流程?



你确定吗?确保函数中有一些cout或printf语句,以确定它们是否运行。


Hi
I am using the sleep function to pause for few minutes, but this sleep function always start first no matter wheree in the program its used. like
....

function1();
sleep(10);
function2();

sleep is executing first .

How this can be solved, I tried to use fflush() before sleep but didn'' t worked

解决方案

Hi
I am using the sleep function to pause for few minutes, but this sleep function always start first no matter wheree in the program its used. like
....

function1();
sleep(10);
function2();

sleep is executing first .

How this can be solved, I tried to use fflush() before sleep but didn'' t worked

Are those functions returning a value?If they do u can do it like:

function1()-on succes returns 1 else returns 0
if(function1()) call sleep();

Savage


No funtions are not returning any value. But why the sleep() function do not follow the sequential flow of the program?


No funtions are not returning any value. But why the sleep() function do not follow the sequential flow of the program?

Are you sure? Make sure you have some cout or printf statements in the functions to know if they run or not.


这篇关于使用睡眠问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆