Showing posts with label introduction. Show all posts
Showing posts with label introduction. Show all posts

Saturday, May 10, 2008

Introduction

Basic input/output



Introduction

Input refers to accepting data while output refers to
presenting data. Every program performs three main functions
accepting data from user, processing it and producing the output.

In C language there are several input and output functions.

These functions are collectively found in IO.h and such
IO function together form a library name stdio.h .

User will require all such library function.

These library functions are classified into three broad categories:

1. Console I/O functions

2. Disc I/O functions

3. Port I/O functions

C preprocessors And macro(Introduction,File inclusion )

C preprocessors And macro



Introduction



The C preprocessor is a tool which filters your source code before it is compiled.
The preprocessor allows constants to be named using the # notation.
The preprocessor provides several other facilities which
will be described here.
It is particularly useful for selecting machine dependent
pieces of code for different computer types, allowing a
single program to be compiled and run on several different computers.
The C preprocessor isn't restricted to use with C programs
only. Programmers who use other languages may also find
it useful, however it is tuned to recognize features
of the C language like comments and strings,
so its use may be restricted in other circumstances.
Set of commonly used Preprocessor Directives and their Functions:

#define defines a macro substitution.
#undef undefined a macro.
#include specifies the files to be include.
#ifdef tests for a macro definition
#ifndef tests whether a macro is not defined.
#if tests a compile-time condition.
#endif specifies the end of #if.
#else specifies alternatives when #if test fails.
These Preprocessor or directives can be divided into three categories:

1. Macro Substitution Directives
2. File Inclusion Directives
3. Compiler Control Directives




File inclusion



The preprocessor directive #include is an instruction
to read in the entire contents of another file at that point.

This is generally used to read in header files for
library functions. Header files contain details
of functions and types used within the library.

It must be included before the program can make
use of the library functions.

Library header file names are enclosed in angle brackets,
< >. These tell the preprocessor to look for the header
file in the standard location for library definitions.

Example: #include

another use for #include for the programmer is where
multi-file programs are being written.

Certain information is required at the beginning of each
program file. This can be put into a file called globals.h
and included in each program file.

Local header file names are usually enclosed by double
quotes, " ". It is conventional to give header files a name
which ends in .h to distinguish them from other types of file.

Our globals.h file would be included by the following
line. #include "globals.h"



Friday, May 9, 2008

Introduction (Header File)

Introduction

The C provides a large number of C functions as libraries. Some of these implement frequently used operations, while others are very specialized in their application.

Wise programmers will check whether a library function is available to perform a task before writing their own version.

This will reduce program development time. The library functions have been tested, so they are more likely to be correct than any function which the programmer might write.

This will save time when debugging the program. For using these files ,certain files are needed to be included in the program which make call to these functions.

These files are known as Header files and they contain macro definition ,type definition, and function declarations.

These header files usually have an extension .h as stdio.h, ctype.h, string.h, math.h, stdlib.h, stdarg.h, time.h etc.

Copyright

Copyright © 2008 C Tutorial, All rights are reserved