help plz i cant do it :(

This is a discussion on help plz i cant do it :( within the C Programming forums, part of the General Programming Boards category; the simple program below increments numbers until a key on the keyboard is hit. I want the program to increment ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    13

    help plz i cant do it :(

    the simple program below increments numbers until a key on the keyboard is hit. I want the program to increment numbers while a key is pressed down by the user and to stop incrementing the numbers when the key (being the space bar) is no longer pressed down. please can someone help me out as im not sure how thats done.....thanks

    Code:
    #include <conio.h>
    #include <stdio.h>
    
    int main (void)
    {
      int sale;
      sale = 000.00;
    
       do{
          clrscr();
          printf("%d", sale);
          delay(150);
          sale += 0.01;
         }while(!kbhit());
    
       return 0;
    }

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    13
    i sussed it out!!!!!!!! it took two days and all i needed was one line :| just posting it up here cos it mite help someone else? bye!!! fizz -x-

    Code:
    #include <conio.h>
    #include <stdio.h>
    
    
    int main (void)
    {
    
      float sale;
      int key; 
      sale = 000.00;
    
               while(!kbhit()){
                                     
                       clrscr();
                        key=getch();
                                           
                    while( getch()!='\n'){
                                                             
                       clrscr();
                       printf("%3.2f", sale);
                       delay(150);
                       sale += 0.01;
                   }
             }
          
       return 0;
    }

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    another thread ?
    http://www.cprogramming.com/cboard/s...threadid=31274


    Please stick to one thread next time.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  2. plz help me...
    By sweetchakri in forum C Programming
    Replies: 1
    Last Post: 03-03-2009, 10:50 PM
  3. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 08:54 AM
  4. Anyone plz help me
    By Rose_Flowers in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-17-2003, 12:01 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 08:44 AM

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