CSE 15 Lecture Notes - Lecture 3: Segmentation Fault, Entry Point, Scanf Format String
Document Summary
Computer"s memory is made up of bits (1s and 0s) which are organized into bytes. A computer"s memory can be visualized via stacked addresses: addresses point towards one byte, divisible by 4, variables are alias for numbers. Each byte in a computer has an address, is a location. What"s in the memory: x = 17 x is l-val. What is in the memory location labeled by y. I take what"s in y and put it in x. Messing that up: int x, y: int *p, p = *x. *b = 17 a[0] = 17: b is alias for a, and both are aliases for the same chunk of memory b[3] == a[3, number between brackets must be int. *b = b[0] = a[0: history: integer and pointer were the same in early days of c, pointers have a type associated with them. *(b+1) = b+4 1 integer, 4 bytes *(b+1*sizeof(int)) *(b+1*sizeof(int): adding/subtracting integers from pointers = good, multiply/divide = bad.