C is FUN

Learning C right now, been wanting to get on this. It's going to be FUN !!


About

  • This repository consists of all the C programming projects done with ALX Africa Full stack Software Engineering course in partnership with Holberton School.
  • All main.c files are prewritten by the school. We build functions that produce a specific output while also taking into consideration edge cases.

Content table

  • 0x00 : Hello, World.
  • 0x01 : Variables,if,else,while.
  • 0x02 : Functions, nested loops.
  • 0x03 : Debugging.
  • 0x04 : More Functions and nested loops.
  • 0x05 : Pointers, arrays and strings.
  • 0x06 : More pointers, arrays and strings.
  • 0x07 : Even more pointers, arrays and strings.
  • 0x08 : Recursion.
  • 0x09 : Static libraries.
  • 0x0A : Argc, argv.
  • 0x0B : malloc, free.
  • 0x0C : more malloc, free.
  • 0x0D : Preprocessor.
  • 0x0E : Structures, typedef.
  • 0x0F : Function pointers.
  • 0x10 : Variadic functions.
  • 0x11 : Write our own printf project.
  • 0x12 : Singly linked lists.
  • 0x13 : More singly linked lists.
  • 0x14 : Bit manipulation.
  • 0x15 : File I/O.
  • 0x16 : Simple Shell.
  • 0x17 : Doubly linked lists.

C Program Compilation

The compilation process has four different steps:

  1. The preprocessing stage
  2. The compiling stage
  3. The assembling stage
  4. The linking stage

Step 1: Preprocessing -E

The preprocessor reads the source code and performs various transformations to it:

  • Expanding macros (replacing all of the macros with their values)
  • Handling include files (replaces the #include macro with the content of the header file specified in <>)
  • Removing comments
  • The results in a new file called a translation unit stored in a file with .i extension (intermediate)

Step 2: Compiling -S

The build phase provides us with assembly code that is unique to the target architecture.

In this step the compiler takes action by taking a preprocessed file which checks for syntax or structure errors (in case of errors the compilation process stops and displays the corresponding errors). After compiling it, it generates an intermediate code in assembly language file.s.

Step 3: Assembing -c

In the third stage of compilation, an assembler is used to convert assembly language into machine code. The assembler takes the code and generates an object file file.o, which contains machine code that is not yet executable because it needs to be mapped to a specific memory address. The linker combines all the object files, resolves references between modules, and corrects the addresses, creating an executable file.

Step 4: Linking

The linker is an important tool in compilation that performs two tasks: resolution and relocation of symbols. It arranges the pieces of object code so that functions in one piece can successfully call functions in others. The linker also adds parts that contain the instructions for the library functions used by the program. The result of this stage is the executable file. usually a.out if -o is not specified.

Author✍️

Acknowledgements 📎

All the work featured in this project was undertaken as an integral part of the curriculum for the ALX-SE program. ALX Africa is a comprehensive online full-stack software engineering program that equips students with the necessary skills and knowledge to excel in the technology industry. The program follows a project-based approach, fostering collaborative learning among peers. By engaging in practical projects, students gain hands-on experience and develop the expertise required for a successful career in software engineering.

For more information, visit this link.