Announcement: This sheet is only helpful for myself, it doesn’t contains anything I think I am good at. Please refer to articles with prefix [RA] for detailed information.

Midterm review notes from All of Programming Chapter 1 - 13

## Chapter 0

Everything is a number.
Everything is a number.
Everything is a number.

Abstraction–the separation of interface from implementation.

The interface of something is what it does, while the implementation is how it does.

## Chapter 1 Introduction

7 Steps

1. Work an example Yyurself
2. Write down what you just did
• replace instance with variables
• find repetition
5. Translation to Code
7. Debugging it

## Chapter 8 Pointers

Can we change? => **p *p p
int **p Yes Yes Yes
const int **p No Yes Yes
int *const *p Yes No Yes
int **const p Yes Yes No
const int *const *p No No Yes
const int **const p No Yes No
int *const *const p Yes No No
const int *const *const p No No No

## Chapter 9 Arrays

Use arrays to initialize structs:

## Chapter 10 Uses of Pointers

in string.h, strcasecmp performs case-insensitive comparision.

string -> int:

This convention is common, as it allows for one to write loops which iterate over the array without knowing a priori how many elemnts are in the array.

## Chapter 11 Interacting With the User and System

System call is a special type of function call that transfers control from the program into the operating system.

### Process Creation

When the command shell wants to run another program, it makes a couple of system calls. First, it makes a call to create a new process(fork). This new process(which is an identical copy of the original, distinguishable only by the return value of the fork system call) then makes another system call(execve) to replace its running program with the requested program. The execve system call takes an argument specifying the file with the binary to run, a second argument specifying the values to pass the new programm as argv, and a third argument specifying the values to pass for envp.

Mode Read and/or write Does not exist Truncate Position
r read only fails no beginning
w write only created yes beginning
a writing created no end
a+ rea/write created no End