C Debugging

From XPUB & Lens-Based wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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