course-c

History

C program – hello.c

#include <stdio.h>

 /* function main - print hello world */
int
main()
{
    printf("hello world!\n");
    return 0;
}

C program structure

Executing hello.c

Compilation process

Pre-processing

Compilation and assembly

Linking

Multiple source files – hello.c

#include "print.h"
/* Function main - Print hello world */
int
main()
{
  print_hello();
}

Multiple source files – print.c

#include <stdio.h>
#include "print.h"
void print_hello()
{
  printf("printing: hello world!\n");
}

Multiple source files – print.h

#ifndef _PRINT_H_
#define _PRINT_H_

extern void print_hello();

#endif //_PRINT_H_

Simple compilation

Complex Compilation - With Error

Complex Compilation – Correcting the Error

Using a Graphical Debugger

Debug Using DDD

Debug using DDD on Linux{height=50%}

Debug Using VS Code

Debug using VS Code{width=50%}

Other Topics