Thread: Do While Loop Error

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    45

    Do While Loop Error

    Hi folks, I have set up the following program to read a series of keys from the keyboard, and then terminate the program. I do this by the use of a do while program that stops once the input reaches a numerical value '10'. This currently however, does not work correctly for me.

    Can anyone tell me what I am doing wrong:

    Code:
    /* interface.c: The include functions designed to control the I/O of the PowerMath System */
    #include <stdio.h>
    
    mathInput() 
    {
         int x=20;
         int input;
         char progInput[x];
         
         do 
         {
             x=1;
             progInput[x]=getc( stdin );
             progInput[x]=input;
             x=x+1;
         } while (input!=10);
              
    }
    
    int main() 
    {
           mathInput();
           
           return 0;
    }

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    and where do you set any value to input variable?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    45
    Thanks,

    the line
    Code:
     progInput[x]=input;
    should have been
    Code:
    input=progInput[x];
    .

    I didnt realize that the two lines were different

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What was wrong with the original thread:
    My Code Does Not Work? Why?

    --
    mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User Maz's Avatar
    Join Date
    Nov 2005
    Location
    Finland
    Posts
    194
    The title of the thread at least

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM