How to Debug C Code in Xcode

Feb. 9, 2017 | smlee36 | #seneca, #c, #beginner, #xcode, #debug, #Raphael

This is a ultra simple tutorial for debugging c program in Xcode.

TOC


Case Study

Sample Program

// An ultra simple debugging example

#include <stdio.h>

int main() {
    
    int num;

    printf("Enter your number (1-10): ");
    scanf("%d", &num);

    while (num < 1 || 10 < num) {
        printf("Input number should be 1 - 10.");

        printf("Enter your number again (1-10): ");


    }

    printf("Your number is %d.\n", num);


    return 0;
}

xcode start image

xcode start image

Debug the Program

Marking break points

xcode start image

xcode start image

scanf("%d", &num);

xcode start image