how to delay the output??

Aug 31, 2009 at 2:40pm
hi everyone~~~~~

just like the title above~~~~~
how to delay the output??

i wanted to output three '.' in a slow motion~~~~
example:

output . (1st second)
output . . (2nd second)
output . . . (3rd second)

can anyone teach me how to do this??
Aug 31, 2009 at 2:42pm
Aug 31, 2009 at 2:44pm
Sleep(unsigned int miliseconds) from windows.h if you are using windows (unistd for linux, correct me if I'm wrong)

BTW - why you always type these tildes?

PS . use @helios advice, my is C-style :P
Last edited on Aug 31, 2009 at 2:49pm
Aug 31, 2009 at 3:40pm
Sleep is the simpler way, but it's also OS-dependant. If you decide on Sleep, make sure you capitalize the S.
Aug 31, 2009 at 5:12pm
Sep 1, 2009 at 1:43am
to helios:
thanks~~~~
i will give it a try on this~~~~

to johnkravetzki:
i am learning C++ recently~~~
and i'm a newbie at programming~~~~
about why i like to put this '~~~'
.... maybe its just kind of habit when i was chatting with other people in online game
its hard to see when i write '.' this symbol~~~~ =.='''

to NGen:
sleep?
do you mean i need to type system("Sleep"); in my source code??

to Duoas:
thanks~~~~
i'll take the examples there as a referrence~~~~~
Sep 1, 2009 at 2:05am
The "Sleep" to which NGen refers is the same as the one used in the Windows section of my code in the link I gave you. (It is a Win32 API function defined in Kernel32.dll .)
Sep 1, 2009 at 2:36am
Here's an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <windows.h>
#include <iostream>

int main( ){
    cout << "5" << endl;
    //  We use 1000 since Sleep takes the amount of time in milliseconds, and 1000 ms = 1 second
    Sleep( 1000 );

    cout << "4" << endl;
    Sleep( 1000 );
    cout << "3" << endl;
    Sleep( 1000 );
    cout << "2" << endl;
    Sleep( 1000 );
    cout << "1" << endl;
    Sleep( 1000 );

    cout << "Congratulations, you've just wasted 5 seconds of your life!";
    cin.get( );
    
    return 0;
}
Sep 1, 2009 at 1:22pm
thanks everyone for helping me~~~~~

i'm using ctime to delay the output~~~~~
and finally i managed to work it out~~~~~~~
now i can send my assignment to my teacher~~~~~

actually my assignment is to design a program which acts like an online booking program for booking flight ticket. users are required to input their name, number of passenger, passport of each passenger.

then users are prompt to select their source and destination~~~~
the application should read from input files, named inBoundFlight.txt and outBoundFlight.txt

then users are prompt to input their departure date
the application will then output the user estimated arrival date and time~~~~

the same information should also be written in an external output text~~~~
Sep 1, 2009 at 8:45pm
Did you know you can tie() the cout stream to another stream?
http://www.cplusplus.com/reference/iostream/ios/tie/
Sep 2, 2009 at 2:21pm
=.=''' no~~~~ i didnt know about it~~~~~~

i followed that link to the tie() ~~~~~
but i didnt quite understand the meaning of the description~~~~~

how to actually use the tie() ??
Sep 2, 2009 at 10:14pm
Why don't you compile and execute the example at the bottom of the link?
Sep 2, 2009 at 11:58pm
i tried to compile already~~~~~

about the *cin.tie() ~~~~~why does it need to include a * in front of it??

is the example same as this??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<fstream>

using namespace std;

int main()
{
      ofstream outData("test.txt");

      cout << "tie example: " << endl;
      cout << "this is inserted into cout. " << endl;
      outData << "this is inserted into the file." << endl;

      outData.close();
}
Topic archived. No new replies allowed.