sleep() command trouble

for windows users, i've seen multiple sleep delays for one output. For example,

#include <iostream>
#include <conio.h>
#include <windows.h>

using namespace std;

int main(){
cout<<"Loading";
Sleep(100);
cout<<".";
Sleep(100);
cout<<".";
Sleep(100);
cout<<".";

this will output: "Loading [delay] . [delay] . [delay] ."

using my mac, however, when i try the same type of code all that outputs is:
"[delay] Loading..." the initial delay is pretty long so the sleep() commands are stacking. Can anyone help me so that my output has delays similar to that of windows?
You need to flush cout to make sure the output is made visible.

 
cout<<"Loading" << flush;
or
1
2
cout<<"Loading";
cout.flush();

hey thanks a lot! here's my working code:

#include <unistd.h>

int usleep(useconds_t usec);

cout << "loading" << flush;
usleep(100000);
cout << "." << flush;
usleep(100000);
cout << "." << flush;
usleep(100000);
cout << "." << endl;

}  
Topic archived. No new replies allowed.