C - System Programming
The C language was originally designed from 1969 to 1972, by Dennis
Ritchie to program the Unix operating system.
The goal of C was to be portable.
C Features
A C program is a set of functions that return or not a value, and global
variables.
Functions and variables have prototypes in header files for external use.
The programmer must manage itself the memory, using pointers and functions
to allocate of free fields of memory.
It is portable with some restrictions, additional variable types for
exemple, are specific to compilers.
Why to use it?
C has known success thanks to the liberty if offers to programmers. The drawback is the difficulty to debug the programs. It is fast, and a large collection of APIs is available.
Description of the C language
Data structures:
Scalars (int, long, char, char *, etc...), struct, union, typedef.Control structures:
- if ... else
- switch ... case ... default
- while
- for
- do ... while
- break, continue, return
- goto
Some symbols:
// and /* */ comments.& | && || logical operators.
# directive to the pre-processor.
The while loop:
while(x < y)
{
... statements ...
}
Defining a function:
int name(char *x, int y)
{
... statements ...
return(z);
}
C Sites and tools
- Introduction
to C
First C curse. - LCC
A 32 bits C compiler with IDE and manual (Win). - Turbo
C 2.01
A free C compiler with textual IDE. You may have to search on the site among archives to found it..(Win) - Cint
C and C++ interpreter. - Development
of C
Article by D. Ritchie.
Libraries
- Graphic 32
A graphical library for C++ builder and Kylix. - SDI
Framework
Library to start an application for Windows without MFC.
Sample code
|
Merging and displaying lists
|
string s = "demo" + "trail";
int l = s.length();
for(int i = 0; i < l; i++)
{
char c = s[i];
printf("%c\n", c);
}
|
