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? :confused:
Printable View
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? :confused:
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...
Forgett about it.....Windows.h. it was...:D
[Edit]But now I am getting linking problems....[/Edit]
Quote:
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.
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).
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.
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....
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?
It's not flushing. Insert a flush in the stream.
cout << '.' << flush;
Hehe...ohhh myyy good...my JAVA knowledge is good as gold...:D
<< endl; will flush the bufferQuote:
Originally posted by CornedBee
It's not flushing. Insert a flush in the stream.
cout << '.' << flush;
But endl also inserts a newline, and if I understand Steve correctly, he wants an app that slowly builds a long chain of dots.
yeah but it will add a "\n" to it too first