Here's the code:
I was able to figure out how to tokenize my sentences, and later, how to use the sleep() function... But now I want to learn how to use the sleep() function on my tokenized sentences. And when I mean sentences, I mean each letter from each word in the sentence; it would look weird if the whole word was appearing, instead of each character.Code:#include <iostream> #include <string> #include <ctime> #include <windows.h> #include <stdlib.h> using namespace std; int main() { string Input ("L o n g a g o , e x i s t e d a r e a l m l i k e n o o t h e r . . . "); string qTokenize(Input); string qDelim(" "); string::size_type qStart(0); string::size_type qEnd; qEnd = qTokenize.find_first_of(qDelim, qStart); while (qEnd != string::npos) { cout << qTokenize.substr(qStart, qEnd - qStart) << endl; qStart = qEnd + 1; qEnd = qTokenize.find_first_of (qDelim, qStart); cout << qTokenize.substr(qStart); sleep(400); }
for example: "Long time,"
I want it to look like:
"L"
"o"
"n"
"g"
" "
"t"
"i"
"m"
"e"
ect..
Instead of:
"Long"
" "
"time"
ect..
And it should be all on one line, just like the sleep() function always does!
But, I can't really think of what functions I could do to acheive what I want... any ideas or tips would be very appreciated!!!
P.S. There was one way I could do it, but it takes so much time and space to do... I did this :
Code:cout << "L"; sleep(400); cout<<"o"; sleep(400); cout << "n"; sleep(400); cout << "g"; sleep(400);
ect....
So what I'm asking is, if there is a shorter way to do this??



LinkBack URL
About LinkBacks


