setting timers and incrementing values

This is a discussion on setting timers and incrementing values within the C Programming forums, part of the General Programming Boards category; k well im trying to make a splash screen show up for a program im making and id like to ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    9

    setting timers and incrementing values

    k well im trying to make a splash screen show up for a program im making and id like to make it so that it shows up for about 7 seconds then disappears on its own then loads up the menu

    what library would i use and what are the commands i would use
    also a sample code would be appreciated

    also i would like to know how i would make a decrementing value if a certain integer is less then 85
    so if i have 85 i get 100%
    84 then 2% less and so on until there is 0%

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >what library would i use and what are the commands i would use
    It all depends on your compiler and operating system. But this is a common question, so a board search will give you solutions for the most common systems.

    >so if i have 85 i get 100%
    >84 then 2% less and so on until there is 0%
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
      int percent = 100;
      int x = 83;
    
      while ( x++ < 85 && percent > 0 )
        percent -= 2;
    
      printf ( "%d%%\n", percent );
    
      return 0;
    }
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    11
    Quote Originally Posted by Prelude
    >so if i have 85 i get 100%
    >84 then 2% less and so on until there is 0%
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
      int percent = 100;
      int X = 83;
    
      while ( x++ < 85 && percent > 0 )
        percent -= 2;
    
      printf ( "%d%%\n", percent );
    
      return 0;
    }
    That's not what the OP asked for.

    He wants to count down from 85 by ones, and 100% by 2s until he hits 0%.

    Code:
    #include <stdio.h>
    
    int main(void)
      { int percent = 100;
        int count = 85;
    
         while (percent > -1)
            { printf( "Count = %d     Percent =  %d\n",count,percent);
               count  -= 1;
               percent -=2; } 
         return 0; }

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >That's not what the OP asked for.
    You can't be sure. The question was ambiguous. Though I appreciate another perspective in case my interpretation of the requirement was incorrect.
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Posts
    11
    Quote Originally Posted by Prelude
    >That's not what the OP asked for.
    You can't be sure. The question was ambiguous. Though I appreciate another perspective in case my interpretation of the requirement was incorrect.
    Not really... he was pretty clear that he wanted a decrementing value where 85 = 100%, 84 = 98% and so on. I just had the thing print it out for him.

    If he's looking for formulas...

    percent = 100 - ((85 - count)*2)

    or

    count = 85 - (percent / 2)

    Should do the job.

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    9
    thanks guys all of those worked exactly how i wanted to

    anyone know how to set a timer for a splash screen now?

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >anyone know how to set a timer for a splash screen now?
    Reread my first post. You'll need to clarify your compiler and operating system before this question can be answered with any semblance of accuracy.
    My best code is written with the delete key.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    9
    k all is good
    btw im using bloodshed
    i used a clrscr to get rid of the splash screen

Popular pages Recent additions subscribe to a feed

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