Creating a loading symbol

This is a discussion on Creating a loading symbol within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I was wondering if anyone knew or had an example code of how they make the loading spinning symbol I've ...

  1. #1
    Unregistered
    Guest

    Creating a loading symbol

    I was wondering if anyone knew or had an example code of how they make the loading spinning symbol I've seen on boot loaders and such where the keys go like this

    | / - and repeat making it look like a spinning line.

    I tried producing it with /b but it didn't work out to well I thought it was a neat effect I could use for some programs while waiting for them to load or do work and was hoping someone could help me out?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    Did you remember to use fflush?

    This works compiled with DJGPP
    Code:
    #include <stdio.h>
    #include <dos.h>
    
    int main ( ) {
        char spinner[] = "|/-\\";
        int i, j;
        printf( "Loading...." );
        for ( i = 0 ; i < 10 ; i++ ) {
            for ( j = 0 ; j < 4 ; j++ ) {
                printf( "%c\b", spinner[j] );
                fflush( stdout );
                delay( 250 );
            }
        }
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

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