C Basics (Part 1)

Structure of a C Program

Building and Running a C Program

Starts with source code, like the first sample program
  1. Pre-processing
  2. Compiling
  3. Linking
  4. Run it!

Variables

Variables are used to store data. Every C variable has a: When a program is compiled, a symbol table is created, mapping each variable name to its type, size, and address

Identifiers

Identifiers are the names for things (variables, functions, etc) in the language. Some identifiers are built-in, and others can be created by the programmer.

Style-conventions (for indentifiers)


Declaring Variables


Atomic Data Types

Atomic data types are the built-in types defined by the C language

Sizes

This program will print the number of bytes used by each type - sizes may vary from system to system
 

Initializing Variables

More Declaration Examples, using various types
 

Constant Variables

(Woohoo! An oxymoron!)

Symbolic Constants (an alternative)

Questions to consider


Other Basic Code Elements

Literals

Literals are also constants. They are literal values written in code.

Escape Sequences


 

Comments

Comments are for documenting programs. They are ignored by the compiler.