Need help tokenizing a word, not (sentences) and than use the sleep() function on 'em

This is a discussion on Need help tokenizing a word, not (sentences) and than use the sleep() function on 'em within the C++ Programming forums, part of the General Programming Boards category; Here's the code: Code: #include <iostream> #include <string> #include <ctime> #include <windows.h> #include <stdlib.h> using namespace std; int main() { ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    67

    Need help tokenizing a word, not (sentences) and than use the sleep() function on 'em

    Here's the code:

    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);
    }
    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.

    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??

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,676
    Have you tried looping through your string character by character?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sleep function
    By pollypocket4eva in forum C Programming
    Replies: 11
    Last Post: 02-16-2009, 03:28 AM
  2. How to use Sleep function?
    By Jake.c in forum C Programming
    Replies: 1
    Last Post: 01-17-2009, 07:36 AM
  3. sleep function
    By osal in forum C++ Programming
    Replies: 5
    Last Post: 05-04-2005, 12:09 PM
  4. Using the sleep function
    By HyperHelix in forum C++ Programming
    Replies: 3
    Last Post: 04-30-2005, 09:18 AM
  5. The sleep function...
    By Finchie_88 in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2004, 03:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21