Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen How to Run the Program? | Introduction
C Basics
course content

Kursinhalt

C Basics

C Basics

1. Introduction
2. Data
3. Operators
4. Control Statements
5. Functions
6. Pointers

book
How to Run the Program?

To transform our code into specific commands for the processor, we need a compiler. The act of compilation goes through several stages:

An executable file is simply a series of instructions (machine code) meant for the processor. For context, the phrase "Hello, c<>definity" in machine code might resemble a sequence.

exe

program

copy
12
01001000011001010110110001101100011011110010110000100000011000110011110000111 110011001000110010101100110011010010110111001101001011101000111100100100001

An intentional error was added to the code below to demonstrate how the C compiler detects and reports issues.

c

Main

copy
12345678
#include <stdio.h> int main() { printf("some text") // Error line return 0; }

The problem arises because the compiler was expecting a semicolon ; at the end of the printf("some text") statement. Without the semicolon, the compiler doesn't recognize the end of the statement, causing it to misinterpret the following return 0; as part of the incomplete printf line. This leads to the error being reported on the next line, even though the real issue is the missing semicolon after the printf statement.

c

Main

copy
123456789
#include <stdio.h> int main() { ;; ;;;;;; printf("C language moment\n");;; ;return 0; ;;; }

The C compiler is quite forgiving when it comes to extra semicolons. While they may look odd, multiple ; instances are treated as empty statements and don't affect the program's behavior. This means the code will still compile and run without issues, even with the excess semicolons. However, it's good practice to avoid unnecessary semicolons to keep your code clean and readable.

What are the steps for compiling?

What are the steps for compiling?

Wählen Sie die richtige Antwort aus

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 3
We're sorry to hear that something went wrong. What happened?
some-alt