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

Course Content

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.

A compiler is a tool that takes your written code and translates it into machine code—essentially a series of 0s and 1s —because that's the language a computer's processor understands. Importantly, the compiler doesn't execute your code; it only translates it.

Note

The compiler processes code sequentially, from top to bottom.

The act of compilation goes through several stages:

  • Preprocessor Operation. At this stage, all #include directives are processed, allowing for the inclusion of external files, libraries, and other necessary elements. Essentially, all required components are integrated into your program;

  • Syntax Error Analysis. If the compiler spots any syntax mistakes within your code, it halts the compilation, highlighting the error for correction;

  • Compilation to Executable File. All components linked with your program are consolidated and translated into an executable file. For instance, on the Windows platform, these files take the ".exe" (executable) extension. Once compiled, you can run this file similarly to how you'd run a computer game or application.

Note

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 like:

01001000011001010110110001101100011011110010110000100000011000110011110000111 110011001000110010101100110011010010110111001101001011101000111100100100001

Don't stress! This numeric language is meant for machines, not us!

An error was purposely included to showcase how the compiler functions.

c

Main

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

Errors

Why does the compiler point out an error on the 7th line's 2nd character when there's nothing amiss there? That's precisely the issue. The compiler anticipates seeing a semicolon ; at that spot. But why does it expect the semicolon there and not right after printf("some text")?

c

Main

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

The compiler is forgiving with excess semicolons, so it'll let you slide with multiple ; instances.

What are the steps for compiling?

What are the steps for compiling?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

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