Thread: looping and input

  1. #1
    zsaniK Kinasz's Avatar
    Join Date
    Jan 2003

    looping and input

    I am trying to get a program to loop infinately, I want it to keep looping until it receives input from the keyboard, this is what i have..

    #include <stdio.h>
    #include <conio.h>

    int main(){

    char userin;

    { stuff...

    userin = getche();
    if(userin = 'g')
    { something else...


    As the program is it will loop (do stuff) once and wait for input, how do i make it continue looping and stop on input

    Any help would be appreciated

    "Assumptions are the mother of all **** ups!"

  2. #2
    Patent Pending GSLR's Avatar
    Join Date
    Sep 2001
    #include <stdio.h>
    #include <conio.h>
    int main()
    int test=1;
    char userinput;
               userinput = getche();
               if(userinput == 'g')test=0;
          return 0;
    And To All Those Opposed, WELL !!!
    >Deleted< " Looks like a serial no."

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    You need a compiler specific function, like maybe kbhit() which will test for input without pausing your program. Search and ye shall find...
    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. String input looping my hash function
    By iAmFedor in forum C++ Programming
    Replies: 6
    Last Post: 04-25-2008, 04:20 PM
  2. looping and condition problems
    By liukinhei in forum C Programming
    Replies: 1
    Last Post: 03-11-2008, 02:40 AM
  3. For loop problems, input please.
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-22-2007, 03:54 AM
  4. looping that clears the friggen page
    By wart101 in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2005, 07:16 AM
  5. Input appears once extra time!?
    By siumui in forum C Programming
    Replies: 3
    Last Post: 11-15-2002, 10:19 PM