Do While Loop Error

This is a discussion on Do While Loop Error within the C Programming forums, part of the General Programming Boards category; Hi folks, I have set up the following program to read a series of keys from the keyboard, and then ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,459
    and where do you set any value to input variable?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    Maz
    Maz is offline
    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, 01: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

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