Node:Basic ideas, Next:, Previous:Using a compiler, Up:Using a compiler

Basic ideas about C

First a note about a programming language that is different from the C programming language, the GNU shell. When you enter commands in the GNU shell, they are executed immediately. Moreover, the shell is a programming language, in that the commands you type are a program, because you can also create a text file containing many shell commands. When you run this file, the commands will be executed in sequence.

On the other hand, consider C. While a shell command file can be executed directly, a C program must be created in two stages:

  1. First, the program is written in the form of text files with a text editor such as GNU Emacs. This form of the program is called the source code. A computer cannot execute source code directly.
  2. Second, the completed source code is processed with a compiler -- a program that generates a new file containing a machine-language translation of the source code. This file is called an executable file, or executable. The executable file is said to have been compiled from the source code.

To run the compiled program, you must usually type the name of the executable file preceded by a period and a slash, as in this example:


The "dot-slash" prefix tells the GNU shell to look in the current directory for the executable. You usually do not need to type ./ in front of commands for programs that came with your GNU system, such as emacs, because the computer already knows where to look for the executables of those programs, which were placed in special directories when your GNU system was installed.

A C program is made up of, among other components, variables and functions. A variable is a way to hold some data which may vary, hence the name. For example, a variable might hold the number 17, and later the number 41. Another variable might hold the word "Sue".

A function is a segment of text in the source code of a program that tells the computer what to do. Programming consists, in large part, of writing functions.