·  C – Introduction

 

- Info:

  - C is Programming Language.

  - C is not OOPL-Object Oriented Programming Language like Java, C++ or C# which means that it only uses functions.

  - C uses pointers for direct memory access which can lead to errors when accidentally writing to non-allocated memory.

  - C doesn't have GC-Garbage Collection like Java or C# which makes memory leaks more probable.

  - C programs created for one OS, like Windows, can't be executed on another OS, like UNIX, without recompiling them.

 

- Creation of Executable:

 

  - C language is used by creating ASCII text file with '.c' extension containing source code:

 

    Hello.c

    #include <stdio.h> 

   

    int main () {

      printf("Hello World");

      return 0;

    }

 

  - Preprocessor goes through such source code replacing macro names with their source code.

 

  - Compiler uses resulting source code to create file with extension '.o' containing object code written in machine language

    gcc -c Hello.c 

 

  - Linker is then used to connect all files with object code into single executable with extension '.exe':

    gcc -o Hello.exe Hello.o

 

  - Once the executable is created you can simply use it by typing it's name:

    Hello.exe

 

- Preferred Highlighting:

 

  - Test.c:

    #include <stdio.h>

   

    int main () {

      /* Multyline

         comment.  */

      printf("%s\n","Hello World"); //Single line comment.

      int var = 10;

   

      return 0;

    }

 

  - Preprocessor:

 

 

Red

Green

Blue

Bold

Example

   

Directives

0

0

255

Y

#include

 

Headers

0

0

0

N

<stdio.h>

 

  - Comments:

 

 

Red

Green

Blue

Bold

Example

   

Multi-line comment

0

128

0

N

/* Multyline

   comment.  */

 

Single-line comment

0

128

0

N

//Single line comment.

 

  - Code:

 

 

Red

Green

Blue

Bold

Example

   

Built-in types

0

0

255

Y

int

 

External SDK Calls

0

0

0

Y

printf

 

Function declarations

0

0

0

Y

main

 

Functions

0

0

0

Y

 

 

Keywords

0

0

255

Y

return

 

Local variable declarations

0

0

0

N

var

 

Local variable references

0

0

0

N

var

 

Numbers

200

0

200

N

10

 

Strings

200

0

200

N

"Hello World"