C notes #
Pointers #
int x = 1, y = 2, z[10];
int *ip; /* ip -> int*/
ip = &x; /* ip -> x */
y = *ip; /* y = 1 */
*ip = 0; /* x = 0 */
ip = &z[0]; /* ip -> z[0]*/
При передаче в функцию, переменные копируются, поэтому для изменения данных во внешней функции нужно передавать указатели.
File open modes #
mode | description | starts… |
---|---|---|
r/rb | open for reading (The file must exist) | beginning |
w/wb | open for writing (creates file if it doesn’t exist). Deletes content and overwrites the file. | beginning |
a/ab | open for appending (creates file if it doesn’t exist) | end |
r+/rb+/r+b | open for reading and writing (The file must exist) | beginning |
w+/wb+/w+b | open for reading and writing. If file exists deletes content and overwrites the file, otherwise creates an empty new file | beginning |
a+/ab+/a+b | open for reading and writing (append if file exists) | end |