CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Marquee

  1. #1
    Join Date
    Feb 2009
    Posts
    11

    Exclamation Marquee

    I am trying to make a marquee, I have made this where the text maves from right to left and also where the text first moves left to right and then right to left.
    What I am trying to do is that when the text moves from left to right it should come out one by one. For example
    o
    lo
    llo
    ello
    Hello
    Similarly the text should go out of the screen in the same manner
    For example
    Hello
    Hell
    Hel
    He
    H

    The Coding for the same is
    Code:
    #include<iostream>
    #include<dos.h>
    #include<conio.h>
    class marquee
    {
    	int a,b,x,y,z;
    	char c[50];
    	public:
    	void display()
    	{
    		cout<<"\nPlease Enter your Name:";cin>>c;
    		cout<<"\nEnter a Choice. 1 for Rotating and 2 for Bouncing: ";cin>>z;
    		for(y=0;c[y]!='\0';y++); 
    		if(z==2)
    		{
    			for(x=1;x>0;x++)
    			{
    				for(a=1;a<80-y;a++)
    				{
    					for(b=1;b<=a;b++)
    					{
    						clrscr();
    						cout<<" ";
    					}
    					cout<<c<<"\n";
    					delay(50000000);
    				}
    				for(a=80-y;a>y;a--)
    				{
    					for(b=1;b<=a;b++)
    					{
    						clrscr();
    						cout<<" ";
    					}
    					cout<<c<<"\n";
    					delay(50000000);
    				}
    			}
    			clrscr();
    		}
    		else if (z==1)
    		{
    			for(x=1;x>0;x++)
    			{
    				for(z=1;z<=x;z++)		\\Starting
    				{
    					cout<<c[y];y--;
    				}
    				for(a=1;a<80-y;a++) 		\\Middle
    				{
    					for(b=1;b<=a;b++)
    					{
    						clrscr();
    						cout<<" ";
    					}
    					cout<<c<<"\n";
    					delay(50000000);
    				}
    			}
    			clrscr();
    		}
    		else
    		cout<<"\nERROR!!!\nYou have entered a wrong choice. Run the program again.";
    	}
    };
    void main()
    {
    	marquee view;
    	view.display();
    }

  2. #2
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Marquee

    Yuck!

    dos.h and conio.h are nonstandard headers.
    main ALWAYS returns an int, never void.
    your compiler is horrifically out of date. turbo c???
    your variable names are among the worst I've ever encountered. c is a name, so call it name. what the hell are a,b,x,y,z and why do they need to be class members??
    cin/cout are undeclared identifiers. cin and cout live in namespace std.
    for the love of god put whitespace around operators!
    cout<<c[y];y--; YUCK! dont jam statements up together like that, its horribly unreadable.

    Code should be self documenting and highly readable. Descriptive variable names and proper indentation and a single statment per line go a long way towards that goal.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  3. #3
    Join Date
    Feb 2009
    Posts
    11

    Re: Marquee

    I am a beginer and I am using all the identifiers which I have been taught so far.
    The compiler is DJGPP not Turbo C. If you can help then its good otherwise please dont post a reply, no one want to know how critical can you be.

  4. #4
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: Marquee

    Thats not criticism.
    DJGPP is a nonstandard compiler last updated before C++ was standardized. You cannot use it to learn C++ really. Theres a link in my sig to two decent free compiler/ide systems. I urge you to use one rather than DJGPP. About the only valid use of DJGPP these days is maintaining legacy dos code.
    Be more descriptive in your variable names. You ask for help but your code is totally unreadable because of terrible identifier choices. A large percentage of people helping on this forum are professional programmers who dont have a lot of free time but give it up for your help when they do. If they cant answer a question fairly quickly, they will move on. To facilitate more help for yourself, you should take on board my comments and make your code more readable.
    I cant copy and paste your code into my compiler and test it because my compiler has no idea what clrscr() and delay() are. These are nonstandard functions and so to run your code I would need to write those functions. This is one of the reasons that DJGPP is not good for you. Use visual C++ or GCC/MinGW and when you want to write a clrscr() and delay() functions I can show you how to do it.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured