C Compiler Logo

Missing Semicolon

Missing Semicolon

syntax

error: expected ';' before '}' token

Description

A semicolon is missing at the end of a statement. In C, most statements must end with a semicolon to indicate the end of the statement.

Common Causes

Example of Error

Error Code

#include <stdio.h>

int main() {
    int x = 5  // Missing semicolon here
    printf("Value: %d\n", x);
    return 0;
}

Solution

Add the missing semicolon at the end of the statement. In C, all statements (except for control structures like if, for, while, and function/block definitions) must end with a semicolon.

Corrected Code

#include <stdio.h>

int main() {
    int x = 5;  // Semicolon added here
    printf("Value: %d\n", x);
    return 0;
}

Additional Tips