Friday, October 31, 2008

Getting Started

WHAT IS AN IDENTIFIER?

Before you can do anything in any language, you must know how to name an identifier. An identifier is used for any variable, function, data definition, etc. In the C programming language, an identifier is a combination of alphanumeric characters, the first being a letter of the alphabet or an underline, and the remaining being any letter of the alphabet, any numeric digit, or the underline. Two rules must be kept in mind when naming identifiers.The case of alphabetic characters is significant. Using INDEX for a variable name is not the same as using index and neither of them is the same as using InDeX for a variable name. All three refer to different variables.
1.According to the ANSI-C standard, at least 31 significant characters can be used and will be
considered significant by a conforming ANSI-C compiler. If more than 31 are used, all characters
beyond the 31st may be ignored by any given compiler.

KEYWORDS

There are 32 words defined as keywords in C. These have predefined uses and cannot be used for any other purpose in a C program. They are used by the compiler as an aid to compiling the program. They are always written in lower case. A complete list follows;
auto
double
int
struct
break
else
long
switch
case
enum
register
typedef
char
extern
return
union
const
float
short
unsigned
continue
for
signed
void
default
goto
sizeof
volatile
do
if
static
while
In addition to this list of keywords, your compiler may define a few more. If it does, they will be listed inthe documentation that came with your compiler. Each of the above keywords will be defined, illustrated,and used in this tutorial.

WE NEED DATA AND A PROGRAM

Any computer program has two entities to consider, the data, and the program. They are highly
dependent on one another and careful planning of both will lead to a well planned and well writtenprogram. Unfortunately, it is not possible to study either completely without a good working knowledgeof the other. For that reason, this tutorial will jump back and forth between teaching methods of programwriting and methods of data definition. Simply follow along and you will have a good understanding ofboth. Keep in mind that, even though it seems expedient to sometimes jump right into coding the program, time spent planning the data structures will be well spent and the quality of the final program will reflect the original planning.

A WORD ABOUT COMPILERS

All of the example programs in this guide will compile and execute correctly with any good ANSI
compatible C compiler. Some compilers have gotten extremely complex and hard to use for a beginning C programmer, and some only compile and build Microsoft Windows programs. Fortunately, most of the C compilers available have a means of compiling a standard C program which is written for the DOS environment and includes none of the Windows extensions. You should check your documentation for the capabilities and limitations of your compiler. If you have not yet purchased a C compiler, you should find one that is ANSI-C compliant, and that also has the ability to generate a DOS executable if you are planning to use the DOS operating system.

No comments: