#1
  1. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    NyC
    Posts
    4
    Rep Power
    0

    scrolling strings


    Im having this problem, I want the user to enter a string and the proggy will scroll is back the the user slowly, but when you enter a " " it messes up and stops before the space. Thanks for the help - here's code.

    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <windows.h>
    #include <string>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
      int length;
      char word[100];
      int curchar = 0;
      int total = 0;
      int lastd = 0;
      int dlay = 500;
      
      cout << "Enter the a string: ";
      cin >> word;
      length = strlen(word);
    
      while (curchar < length)
      {
        total = lastd + dlay;
      
        if (GetTickCount() > total)
            {
                    lastd = GetTickCount();
                    cout << word[curchar];
                    curchar++;
            }
        }
      
      cout << "\n";
      system("PAUSE");	
      return 0;
    }
  2. #2
  3. Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    NyC
    Posts
    4
    Rep Power
    0

    nM got it


    thx anyway but heres the fixed code if your interested -
    Code:
    #include <iostream>
    #include <stdlib.h>
    #include <windows.h>
    #include <string.h>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
      int length;
      char word[100];
      int curchar = 0;
      int total = 0;
      int lastd = 0;
      int dlay = 500;
      
      cout << "Enter the a string(max is 99 chars): ";
      cin.getline (word,100);
      cout << "Enter a Delay in GetTickCount(millis): ";
      cin >> dlay;
      length = strlen(word);
    
      while (curchar < length)
      {
        total = lastd + dlay;
      
        if (GetTickCount() > total)
            {
                    lastd = GetTickCount();
                    cout << word[curchar];
                    curchar++;
            }
        }
      
      cout << "\n";
      system("PAUSE");	
      return 0;
    }

IMN logo majestic logo threadwatch logo seochat tools logo