|
-
Dec 21st, 2003, 06:18 PM
#1
Thread Starter
Frenzied Member
Sleep freezes everything?
i have a loop
while(true)
{
cout<<".";
Sleep(60000);
}
which should print a period every minute. but i get nothing, even when i turn it down to 100 i get nothing. why?
-
Dec 21st, 2003, 06:43 PM
#2
No idea right now....but just wondering. I have never used Sleep before in C++ only in Bach. But if I add it it says undecleared indentifier...do I have to include anything to use it? MSDN doesn't say anything abou it...
-
Dec 21st, 2003, 06:44 PM
#3
Forgett about it.....Windows.h. it was...
[Edit]But now I am getting linking problems....[/Edit]
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/sleep.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
-
Dec 21st, 2003, 11:37 PM
#4
Addicted Member
Sleep freezes the current thread (thread the function was called from) and all execution within that thread until the interval is up.
I believe using SleepEx API returns a value when the thread continues (interval for function is up).
-
Dec 22nd, 2003, 04:28 AM
#5
I think he knows that....but it should print something every minute.....or at least about every minute.It might be slowed down a bit of the system. But it is not supposed to freeze the whole app.
-
Dec 22nd, 2003, 06:17 AM
#6
Hyperactive Member
i think there is a function called delay - u may use that instead of sleep...
also if it is not priniting even a single '.', check if it goes inside the loop or not... although it seems that it should....
-
Dec 22nd, 2003, 06:32 AM
#7
I have no idea how the cout is actually working. But is it always flushing the buffer like println in java? If not....maybe the loop is to tight so it is never able to flush the buffer?
-
Dec 22nd, 2003, 08:07 AM
#8
It's not flushing. Insert a flush in the stream.
cout << '.' << flush;
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 22nd, 2003, 11:43 AM
#9
Hehe...ohhh myyy good...my JAVA knowledge is good as gold...
-
Dec 23rd, 2003, 01:21 AM
#10
Originally posted by CornedBee
It's not flushing. Insert a flush in the stream.
cout << '.' << flush;
<< endl; will flush the buffer
-
Dec 23rd, 2003, 05:52 AM
#11
But endl also inserts a newline, and if I understand Steve correctly, he wants an app that slowly builds a long chain of dots.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 23rd, 2003, 05:53 AM
#12
transcendental analytic
yeah but it will add a "\n" to it too first
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|