C Debugging

From XPUB & Lens-Based wiki

Starting point from Clapping Music

#include "stdio.h"
#include "string.h"

int i = 0;

char *pat = "xxx xx x xx ";
int patlen;


int main () {
    patlen = strlen(pat);
    
    i = 1;
    while (i < 100) {
        printf("%s\n", pat);
        i = i * 2;
    }    
}

Compile with the -g option:

gcc -g loop.c -o loop

Then use the ddd program (frontend to gdb) to debug the program.

ddd loop