void introtxt(char* letter) {
cout << letter;
Sleep(40);
}
this doesnt work on my compiler. i define the letters, but it sleeps for like 10 seconds and then print all th letters fast and quits. why?
void introtxt(char* letter) {
cout << letter;
Sleep(40);
}
this doesnt work on my compiler. i define the letters, but it sleeps for like 10 seconds and then print all th letters fast and quits. why?
You'll need to flush the output -
cout << letter << flush;
To get help with Sleep() you'll have to state your compiler as it's not a standard function.
#include <iostream>
#include <ctime>
using namespace std;
void sleep()
{
double seconds = 1.5;
clock_t timer;
timer = clock() + seconds * 1000;
while (clock() < timer) {}
}
int main()
{
cout << "I am now!!!" << endl;
sleep();
cout << "I am 1.5 seconds later" << endl;
return 0;
}
I think this should work, if I remember I got it correct
Good luck!!
If you want to one char printed, with a pause after each character, then you need to make a for loop, and.. well it will look something like this.
char Text[] = "Hello my name is Rocky";
for (int i = o;Text[i] != '\0';i++)
{
cout << Text[i];
sleep();
}
I think that Im right, but if im wrong, I hope that someone will correct me!!
Sleep(40);
that would be 40 milliseconds.... pretty fast I should think.
1000 milliseconds equals 1 second.
hmmm....
Blue
I think that it´s more fun to do it with clock_t instead..
But if you prefer sleep(); then thats cool to!!