Programming in C - Learning the Ins and Outs



Its great that this big powerful computer can crunch numbers and all, but even a pocket calculator allows for human input. What good is a calculator that gives the same answer, calculating the same problem every single time.

Seems like it would be an ideal time to find out how to tell a computer to allow us to input stuff. Try out this program:


/*----------------- Keyboard Input Program ---------------------------*/
#include <stdlib.h>
#include <stdio.h>

int ch;


void main()




This highly sophistocated program allows you to type something on the keyboard, and mimics on the screen what you typed. You could actually type an entire letter to congress if you chose, but it would only acknowledge the first letter ( ascii character ) that you entered. While this is not all that practical in and of itself, it could be used in conjunction with other programs too.

How to lock up your computer:

If you create a for statement like this:



you have created an "infinate loop". Note that in this for statement, there are no expressions at all in the 3 expression fields. Because of this, it will execute again and again without stopping.

It is possible to use this type of a loop to find out "how many" executions you need to create your "timing loop" ( or for whatever other reason. You can simply do it like this:



but somehow, you have to leave a means of escaping the loop - a break statement of some kind. So the question is, how do you create a "conditional loop"? Here is an example of a conditional loop that will let you keep inputting letters until the "escape" letter is entered:

On The Following Indicator...
( GREEN will indicate your current location)
1 2 3 4 5 6 7 8 9 10

[ ElectronicsTheory.Com ]



THINK FREELY!  Keep Electronics Education Free for the masses by buying form the EE store!




This Course was written by Ray Dall © All Rights Reserved.
This page and all it's content Copyright, Trademarks, Intellectual Properties
and other legal issues 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Ray Dall.
All Rights Reserved.
And for what it's worth... this page was last updated HexDate 01-11--7D1

VISITORS:
Add Me!