Simple question I hope. I have a function that keeps prompting for user input (characters) and returns a character once it finds that the input is valid under certain conditions. I’m writing tests for this and other similar functions, but don’t know how to fake user input. By the way, I’m using scanf() to get user input.
Share
You can change the behaviour of standard input to read from a file with
freopen. Place the test input in a file and call this before your test.