Our reference
- Chapters 1 to 6 and 13 of An Introduction to the C Programming Language and Software Design
But let’s start with some Fall 2015 CSCI 255 notes on C vs Java or the Fall 2011 ECE 209 C overview.
Chapter 1 — Introduction
- Designed to compete with assembly language
- Has a
goto - No objects
if,whileandfor- but
the condition is an
intnot aboolean
- but
the condition is an
- C preprocessor
Chapter 2 — Types, Operators, and Expressions
- Similar integer types to Java but weaker standardization of size
- Is the largest
int32767 or 2147483647? - No boolean,
intdoes the job - No
bytein C - Java
charis like a Cunsigned short
- Is the largest
- Standard C I/O is important and influenced Java I/O (more O than I)
- Similar cast operations, but narrowing without cast is allowed
Chapter 3 — Branching and Iteration
- Looks like Java with a
goto
Chapter 4 — Functions
- functions are not methods
- C has function prototypes to specify the
function interface
- See
fprintfman page
- See
- The
mainfunction returns an integer to indicate success or failure - C standard library has many useful functions
Chapter 5 — Scope and Extent
This is not Java.
Chapter 13 — Input and Output
- %[flags][width][.precision][length]specifier
- The C/C++
printfis a bit like the Javaformat
- The C/C++
- %[*][width][length]specifier
- The C/C++
scanfis very different from the JavaScanner - C input uses pointers
- The C/C++
- Blame it all on FORTRAN
- In practice C++ I/O, with its heavy use of operator overloading and multiple inheritance, does not look at all like C and Java I/O
- File control:
fopenandfclose - Stream access
- Random access:
fseekandftell - Command line arguments
- Fall 2010 ECE 209 formatting notes