Example

Debugging Common C Syntax Errors: A 'Hello, World!' Example

Debugging is the process of identifying and resolving errors in a program. As an illustration, consider this initial C code for a 'Hello, World!' program which contains bugs:

Buggy Code:

#include <stdio.h> int main() { printg("Hello, World!") return 0; }

This program fails due to two specific syntax errors:

  1. Incorrect Function Name: The standard C library function for printing output is printf, not printg.
  2. Missing Semicolon: In C, every statement must be terminated with a semicolon (;). The line with the print function call is missing it.

Corrected Code: By fixing these two bugs, we get the correct version of the program:

#include <stdio.h> int main() { printf("Hello, World!"); return 0; }
Image 0

0

1

Updated 2025-10-10

Contributors are:

Who are from:

Tags

Ch.2 Generative Models - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences