By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,137 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,137 IT Pros & Developers. It's quick & easy.

Wait, pause, sleep, w/e

P: n/a
Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than

Dec 19 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"3than7" <el*****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than

#include <ios>
#include <iostream>
#include <ctime>
#include <string>

void status (const std::string text,
unsigned int duration,
unsigned int interval)
{
std::cout << text;
std::time_t last;
std::time_t begin(std::time(0));

while(std::difftime(last = std::time(0), begin) < duration)
{
while(std::difftime(std::time(0), last) < interval)
; /* empty statement */

std::cout << '.' << std::flush;
}
}

int main()
{
status("connecting", 10, 2);
std::cout << " Done.\n";
return 0;
}
-Mike
Dec 19 '06 #2

P: n/a

Mike Wahler wrote:
"3than7" <el*****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than


#include <ios>
#include <iostream>
#include <ctime>
#include <string>

void status (const std::string text,
unsigned int duration,
unsigned int interval)
{
std::cout << text;
std::time_t last;
std::time_t begin(std::time(0));

while(std::difftime(last = std::time(0), begin) < duration)
{
while(std::difftime(std::time(0), last) < interval)
; /* empty statement */

std::cout << '.' << std::flush;
}
}

int main()
{
status("connecting", 10, 2);
std::cout << " Done.\n";
return 0;
}
-Mike

Thank you very much, but is this the simpilist way to do this, because
i'd like to be able to use this feature elsewhere, and im not sure
exactly what you did there. Thanks ALOT thou, very helpfull.

Dec 19 '06 #3

P: n/a
3than7 wrote:
Mike Wahler wrote:
>"3than7" <el*****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googleg roups.com...
>>Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than

#include <ios>
#include <iostream>
#include <ctime>
#include <string>

void status (const std::string text,
unsigned int duration,
unsigned int interval)
{
std::cout << text;
std::time_t last;
std::time_t begin(std::time(0));

while(std::difftime(last = std::time(0), begin) < duration)
{
while(std::difftime(std::time(0), last) < interval)
; /* empty statement */

std::cout << '.' << std::flush;
}
}

int main()
{
status("connecting", 10, 2);
std::cout << " Done.\n";
return 0;
}
-Mike


Thank you very much, but is this the simpilist way to do this, because
i'd like to be able to use this feature elsewhere, and im not sure
exactly what you did there. Thanks ALOT thou, very helpfull.
There are other options depending on your platform. POSIX systems have a
"sleep" function, for example. The advantage of Mike Wahler's approach
is that it is all standard C++, so it should work anywhere that has a
C++ compiler.

--
Alan Johnson
Dec 19 '06 #4

P: n/a

yes, i played around with it and figured out how to make it work for my
purposes
thanks a bunch mike!

Dec 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.