Based on http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-087-practical-programming-in-c-january-iap-2010/lecture-notes/
gcc -g -O0 -Wall hello.c -o 1.o
and
gdb 1.o
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from ../1.o...done.
(gdb)
(gdb) run
Starting program: ../1.o
hello, 6.087
Program exited normally.
(gdb) quit
Big-endian vs little-endian
#include <stdio.h>
unsigned short x = 1; /* 0x0001 */
int main(void)
{
printf("%s\n", *((unsigned char *) &x) == 0 ? "big-endian" : "little-endian");
return 0;
}
Postfix vs Prefix
Postfix
• y=x++ is a short cut for y=x;x=x+1. x is evaluated before it is
incremented.
• y=x−− is a short cut for y=x;x=x−1. x is evaluated before it is
decremented.
Prefix
• y=++x is a short cut for x=x+1;y=x;. x is evaluate after it is
incremented.
• y=−−x is a short cut for x=x−1;y=x;. x is evaluate after it is
decremented.