Table of Contents

John's C notes

This page isn't meant for anyone apart from the author. Please don't use these notes as they could well be wrong and probably don't make much sense.

General notes

The compiler compiles each file and include as an object file, then links them together with startup code.

  1. Don't forget to prototype functions
  2. %e is format specifier to represent numbers in exponential form: 1.23E+39 or whatever
  3. %ld is format specifier for longs and %lld for long longs.
  4. %le - long double, note %d is DECIMAL, not double.
  5. %o - octal
  6. %x - hex
Store constants in program as specified lengths (don't waste bits):
0xa9 - hex constant
0664 - octal constant
65   - int constant
65u  - unsigned int constant
65L  - long constant
65UL - unsigned long
65LL - long long
65ULL - unsigned long long

Types

There are minimum sizes for the different types (as laid out by the specs of C99 etc), these are:

  • char: 1 byte, 8 bits.
  • short and int: -32,767 to 32,767 (16bit) - you might be better off using short, as int will generally be 32bits.
  • long: -2,147,483,647 to 2,147,483,647 (32bit)
  • long long: -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807 (64bit)
  • unsigned short and unsigned int: 0 to 65,535
  • unsigned long: 0 to 4,294,967,295
  • unsigned long long: 0 to 18,446,744,073,709,551,615
  • float: 6 digits (-37 to 37)
  • double: 10 digits (-37 to 37)
  • long double: at least 10 digits (probably more) (-37 to 37)
  • _Bool - 1 bit.
  • _Complex and _Imaginary - weird shit we probably won't need.
 
c_notes.txt · Last modified: 2010/02/19 05:58 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki