C Debugging

From XPUB & Lens-Based wiki
Revision as of 14:10, 2 November 2010 by Michael Murtaugh (talk | contribs) (Created page with "Starting point from Clapping Music <source lang="c"> #include "stdio.h" #include "string.h" int i = 0; char *pat = "xxx xx x xx "; int patlen; int main () { patlen =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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