A brief Introduction to C99 – Part1

Chapter 1 – A Brief Introduction to C/C++

This chapter will introduce the reader to the brave world of C and C++. Working with C is not an easy task, it’s a world outside, it takes time to be a good developer on C. I learn C and C++ at high school and I never stopped since then. Sometimes, I took time to achieve my tasks too nowadays. To become a good coder, you must struggle.

The days are to be fought; think you have a goal to be one of them.

This chapter will be brief, I will talk about variables, enumeration, struct, perhaps matrices to 4x4x4, are harder to achieve. As C ansi does not have OOP (Object Oriented Programming), I will talk when I wrote about templating or common use STL.

In C or C++ even on Java, every language has a way to make enclosures, iterations, loops.

 In this chapter, I would like to present if/else, while, for(loop).

For instance, an if clause can be to make decisions.



return num1;


return num2;


Imagine do you want to make an infinite loop for an Application Non- Ending Loop, being hardcoded like Amiga OS or write hardcoded POSIX software Kernel.



//do the task;


Are so many ways to do it. A for loop is more like to run in matrices, think on a matrix, a follow the list. A for loop can be considered to run a list, dictionary a lambda way to sort.


for(i=0; i<=list[i]; i++)


//do the task;



Structs are a sort of function to struct a type of elements with n elements inside


struct [structure tag] {

   member definition;

   member definition;


   member definition;

} [one or more structure variables]; 

Struct Books Exemple:

struct Books {

   char  title[50];

   char  author[50];

   char  subject[100];

   int   book_id;

} book; 


#include <stdio.h>

#include <string.h>

struct Books {

   char  title[50];

   char  author[50];

   char  subject[100];

   int   id_book;


int main( ) {

   struct Books Book1;        /* Declare Book1 of type Book */

   struct Books Book2;        /* Declare Book2 of type Book */

   /* book 1 specification */

   strcpy( Book1.title, “C Programming”);

   strcpy( Book1.author, “Nuha Ali”);

   strcpy( Book1.subject, “C Programming Tutorial”);

   Book1.book_id = 6495407;

   /* book 2 specification */

   strcpy( Book2.title, “Telecom Billing”);

   strcpy( Book2.author, “Zara Ali”);

   strcpy( Book2.subject, “Telecom Billing Tutorial”);

   Book2.book_id = 6495700;

   /* print Book1 info */

   printf( “Book 1 title : %s\n”, Book1.title);

   printf( “Book 1 author : %s\n”, Book1.author);

   printf( “Book 1 subject : %s\n”, Book1.subject);

   printf( “Book 1 book_id : %d\n”, Book1.id_book);

   /* print Book2 info */

   printf( “Book 2 title : %s\n”, Book2.title);

   printf( “Book 2 author : %s\n”, Book2.author);

   printf( “Book 2 subject : %s\n”, Book2.subject);

   printf( “Book 2 book_id : %d\n”, Book2.id_book);

   return 0;



Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain.

enum State {

true = 1, false = 0


// In both of the below cases, “day” is

// defined as the variable of type week.

enum week{Mon, Tue, Wed};

enum week day;

// Or

enum week{Mon, Tue, Wed, Thur,Fri}day; // An example program to

//demonstrate working

// of enum in C


enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun}day;

int main()


    //enum week day;

    day = Wed;


    return 0;

C – Bubble Sort

Hello Everyone!

One of these days I decided to solve a sort of data with C, using c99.

I tried to solve it as a issue for my filesystem implementations.

&lt bubble (item,count) char *item; int count; { register int a,b; register char t; for(a=1;a=a;–b){ if(item[b-1]> item[b]){ /* elements to exchange */ t = item[b-1]; item[b-1] = item[b]; item[b]=t; } } }

main() /* main function of the bubble sort */ { char s[80]; int count; sprintf(“enter a string:”); gets(s); count = strlen(s); bubble(s,count); printf(“the sorted string is : %s”, s); return 0; }

As I did the workaround.

ELF – Tutorial Part 1

Hello everyone!

Today I will be talking about ELF, a format used well used nowadays on micro technology although on open systems already in use on the market.


#include <stdio>

#include <iostream>

int main()


printf(“hello world\n”);

return 0;



gcc -o main.c a.out

This is our example to use and verify ELF format. It’s a format used since 1999, as a standard. It can be called a standardisation.

With ELF we can, debug, study how the behaviour of the system have under the CPU and the format CPU smp. It can run on 32 bit and 64 bit cpu.

In Linux if you want to have a describe style for the format, you can run this command on the terminal or in MacOS (Terminal or iTerm2)


file a.out or the name you gave file main.out


To make use of debugging under ELF format is useful to study how the Operating System behaves. Perhaps the libraries are built or their behave too.