Logbook + Scratchpad

macOS

Today I had an issue with running a basic C program on macOS. I was using iTerm2 as a terminal, and it took me a while to find out that it was a terminal issue rather than a code issue.

The C code included a scanf to read a number from the terminal. The problem was that hitting the Return key would print a ^M instead of an actual newline, hanging up the program unless I hit a Ctrl + D.

The solution was to reset the TTY settings with stty sane. Reference: https://superuser.com/a/1501021

#macOS #TTY