Butingtaon's Corner

Posts by type
Other

ANSI C

The lingua franca of Unix, from which modern operating systems like Linux, BSD's and MacOS, are derived from in some way or another.

It is a systems implementation language, which means that it allows some very abstracted manipulation of what would normally be low-level data, like memory locations and such. It has been called "Portable Assembly" for this reason.

void (*fn_array[])(type *) = {fn_name1, fn_name2, ...}

Array of function pointers.


`var++` - return the value of `var` and then increment.

`++var` - increment the value of `var` then return its value.


while (*ptr) { /* Do something with *ptr */ ptr++; }

Iterate over array via pointer math, will only work if the last array item is NULL. Useful for strings.


while (*ptr1++ = *ptr2++) ;

Copy contents of one array to another


Types in C differ in bit length. Otherwise, everything is just a bit pattern.

TypeBit LengthRange
signed char8 bits-127, +127
unsigned char8 bits0, 255
signed short16 bits-32767, +32767
unsigned short16 bits0, +65535
intimplementation-specificsee left.

The types I listed above are the ones I usually work with.


  • Bitwise AND extracts.
  • Bitwise OR sets.
  • Bitwise XOR toggles.
I had been having a blast developing my data structures library from within emacs in termux, most of my tools work well, except for valgrind. When i run any program on valgrind i get errors related to unsupported opcodes