Line endings

Windows: \r\n (ASCII 13, 10)

macOS / Unix / Linux: \n (ASCII 10)

Which one you get is decided by where the file was created, not by where it runs.

EOF

EOF is -1.

Reading a character

scanf("%c",&ch) is equivalent to ch=getchar().

cstring

strlen is $O(n)$.

Floyd

Running the loop order i,j,k three times is fine.

if-else

1
2
if(expr_a)if(expr_b)expr_c
else expr_d

Here expr_d binds to expr_a.

Enlarging the stack

Windows: "-Wl,--stack=<size>"

Linux: "-Wl,-z,stack-size=<size>"

macOS: "-Wl,-stack_size,<size>"

-Wl means the argument that follows is handed to the linker. Linkers differ across platforms, hence three different flags. Also, ulimit -s <size> does nothing on macOS.

Sanitizers

What they do: catch runtime errors.

How to use: "-fsanitize=address,undefined,leak"

On Linux, g++ supports AddressSanitizer, UBSanitizer and LeakSanitizer.

On macOS, Apple clang supports AddressSanitizer and UBSanitizer; Homebrew g++ supports neither.

On Windows, clang supports AddressSanitizer, UBSanitizer and LeakSanitizer; MinGW supports none of them.