blinking output

This is a discussion on blinking output within the C++ Programming forums, part of the General Programming Boards category; Hi Is there any way to get output text (cout) blinking Thanks Wanex...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    6

    blinking output

    Hi

    Is there any way to get output text (cout) blinking

    Thanks

    Wanex

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Not directly... though with a little ingenuity, you could figure out something. Perhaps have the output cleared and re-outputted every 1/2 second with alternating colors... One the color of the background, the other not.
    Sent from my iPadŽ

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    here's one way to do it:
    Code:
    #include <iostream>
    
    int main()
    {
    	for(register short int i=0;i<3000;i++)
    	{
    		if(i<1500)
    		{
    			std::cout<<"\b\b\b\b\b\b\b\b\b\b\b"
    				<<"Hello      "<<std::flush;
    		}
    		else
    		{
    			std::cout<<"\b\b\b\b\b\b\b\b\b\b\b"
    				<<"      World"<<std::flush;
    		}
    
    		i=(i+1==3000?0:i);
    	}
    	return 0;
    }
    ...but don't do that... and the speed of the blinking depends on your computer... it'll try to make it blink as fast as it can...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    6
    Works fine, thank you

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    no, doesn't work fine... don't use that... check your processor when you run that code >.<
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  6. #6
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    MS-DOS 6.X and earlier had a blinking text attribute bit. But according to this Microsoft uses that bit for something else, probably because it was rarely used by anybody. Myself, I think blinking text is hideous and any programmer using it should be shot on site

  7. #7
    I Write C++ Apps, Sue Me.
    Join Date
    Feb 2006
    Location
    In My Computer
    Posts
    44
    Yeah, That Code Is Way To Hard On The Processor. When I ran the code, My CPU Usage went up From 0% to 45%.

    -Kyle

  8. #8
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    Code:
    int main()
    {
      while(1)
      {
        system("cls");
        Sleep(200);
        cout << "Blinking output";
        Sleep(200);
      }
    }
    don't forget to include <windows.h>
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 03:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

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