Source: https://www.physics.ohio-state.edu/~ntg/780/handouts/interactive_input_in_C.pdf