How To Scroll Your Text

This is a discussion on How To Scroll Your Text within the C++ Programming forums, part of the General Programming Boards category; Code: #include <string.h> #include <conio.h> #include <ctype.h> #include <windows.h> int main(int argc, char *argv[]) { char sentzz[]="HELLO I AM A ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    How To Scroll Your Text

    Code:
    #include <string.h>
    #include <conio.h>
    #include <ctype.h>
    #include <windows.h>
    
    int main(int argc, char *argv[])
    {
    char sentzz[]="HELLO I AM A TEXT SCROLL\n"
                 "
    int x;              //special dialogue
    int size; 
    
    size=strlen(senta);
        for(x=0;x<size;x++)
        {   
            Sleep(40); 
            printf("%c",senta[x]);
        }
        getch();
        }

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    it would be a great idea to include some description, such as "i'm getting some build errors I can't decipher" or "point out where my logic is wrong." I can tell you that you're missing a semi colon after the text string, and you're taking the strlen of senta, which is undeclared. You're also indexing senta.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    Sorry, I mis typed a little!

    1. REPLACE the zz in char sentzz and make it read char senta[]="Hello Im Text\n";

    because you have already declared x and size, you should get NO compile errors.
    I do appoligise for my prevoius post, I was a little tired.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    36
    Here is a scroller program that i made

    Code:
    /*
      Name: Scroller
      Copyright: 2005
      Author: Sridar Ravi
      Date: 05/04/05 18:31
      Description: A scrolling text program
    */
    
    
    #include <iostream>
    #include <time.h>
    
    using namespace std;
    //*****************************************************************************
    void wait(long milliseconds)
    {
      long timeout = clock() + milliseconds;
      while( clock() < timeout ) continue;
    }
    
    void Scroll(string &msg)
    {
           string scrolled,temp,temp2;
           
           temp=msg.substr(1,(msg.length()));
           temp2=msg.substr(0,1);
           
           msg=temp+temp2;
           if(msg.length()+1==' ')
           {
                                cout<<temp+' '+temp2;
                                }
           else
           {
           
           cout<<msg;
           }
           }
    //*****************************************************************************       
    int main()
    {
        string msg;
        cout<<"Enter the message that you wish to display as scroller: ";
        getline(cin,msg);
        msg=msg+". ";
        int x=0;
        
        while(1)
        {
                   Scroll(msg);
                   wait(100);
                   system("cls");
                   
                   x++;    
                   }
        cin.get();
        return 0;
    }
    Hope it helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text Scroll Messages
    By peckitt99 in forum C++ Programming
    Replies: 0
    Last Post: 11-14-2007, 02:14 AM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 01:59 PM
  3. Scrolling text with variable pitch fonts
    By Raison in forum Windows Programming
    Replies: 0
    Last Post: 06-02-2004, 08:20 AM
  4. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 04:33 PM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM

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