Introduction to C and Memory Management
Hello, world!
A “Hello, world!” program would look something like so:
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
return 0;
}
You can then compile and run with the following commands:
$ gcc hello.c
$ ./a.out
Hello, world!
Properties of C
Advantages
- C is almost a portable assembly language. It is as close to the machine as possible while it is almost universally available for existing processor architectures.
- Arbitrary memory address access and pointer arithmetic.
- Deterministic usage of resources that fit for resource-limited systems.
- C has a very small runtime. The memory footprint for its code is smaller than for most other languages.
- Many implementations of new algorithms in books are first (or only) made available in C by their authors.
- C is an old and widespread language – it’s easy to find all kinds of algorithms written in C.
Disadvantages
- No concept of Object Oriented Programming (OOP).
- No concept of namespace.
- No constructor or destructor.
- Difficult to debug.
- Compilers cannot handle exceptions (run-time errors).
- No strict data type checking:
- An integer value can be passed for floating datatype.