How to make a flickering string?

This is a discussion on How to make a flickering string? within the C Programming forums, part of the General Programming Boards category; Is there any method in C that let me make a string which disappears and appears after a specific time ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    17

    How to make a flickering string?

    Is there any method in C that let me make a string which disappears and appears after a specific time (time which I will determine during programming).

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    I suppose you could do

    Code:
    printf("hello");fflush(stdout);
    Then do something like
    Code:
    printf("\b\b\b\b\b     \b\b\b\b\b");fflush(stdout);
    And repeat as necessary with time intervals.

    If you want anything more refined, you need to say which OS/Compiler you're using.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    17
    I'm using Windows 7 Ultimate 64bit. The compiler is gcc.
    I didn't get how the above works. It's because it's the first time that I have to deal with fflush().
    Could you either explain to me the above code and how it works, or describe to me another method?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    > I didn't get how the above works.
    But you've only had at most 10 minutes to figure that out.

    > It's because it's the first time that I have to deal with fflush().
    Interesting - have you heard of manual pages or google?

    > Could you either explain to me the above code and how it works, or describe to me another method?
    Could do - but I'm not going to.

    Not until you've at least posted YOUR attempt at actually trying to use that information, and reported on what you found.
    Frankly, throwing it back at me after only 10 mins makes me wonder why I bothered.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Apr 2011
    Posts
    17
    I've already opened some tabs and I'm reading about stream and files in general, because fflush() has actually to do with files. I just asked for another way of doing this thing, not because I'm bored of studying on my own, but because I was wondering if it is possible to be dealt without the knowledge of FILES in C. Don't be so critical of me.

    P.S. I've created a simple version of the game connect-four as an excercise for my university and I just want to make the announcement of the winner more spruce. It's not that I want just a solution to my problem.I've only asked for a possible way of doing this without using stream and fflush() but that's ok.
    Last edited by Cevris; 05-03-2011 at 04:40 AM.

  6. #6
    Registered User
    Join Date
    Apr 2011
    Location
    Bangalore
    Posts
    20
    I think you can try
    Code:
    LOOP:
    printf("Hello");
    sleep(100);
    system("cls");
    sleep(100);
    goto LOOP;

  7. #7
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,620
    Quote Originally Posted by ShashiKantSuman View Post
    I think you can try
    Code:
    LOOP:
    printf("Hello");
    sleep(100);
    system("cls");
    sleep(100);
    goto LOOP;
    LOL, you certainly have learned that from an 80s school or code!
    Devoted my life to programming...

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Sipher View Post
    LOL, you certainly have learned that from an 80s school or code!
    Gees for a minute there I thought I was looking at BASIC code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to make my own reverse string
    By Joelito in forum C Programming
    Replies: 3
    Last Post: 06-19-2007, 08:29 AM
  2. flickering
    By ElastoManiac in forum Windows Programming
    Replies: 10
    Last Post: 12-23-2005, 07:26 AM
  3. Trying to make a string identifier
    By Frantic- in forum C++ Programming
    Replies: 22
    Last Post: 06-13-2005, 12:36 AM
  4. flickering
    By lambs4 in forum Game Programming
    Replies: 9
    Last Post: 07-25-2002, 02:51 PM
  5. Flickering
    By Visu A in forum C Programming
    Replies: 1
    Last Post: 02-26-2002, 11:48 PM

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