How can I detect a space or newline at the end of scanf()?
问题 I'm writing a program where I have to accept commands from the user like a shell where the user can set values for environment variables. The problem I'm having is if the user types set var var-value I need to know the user typed a space instead of just set and pressed enter which is a different command. How can I determine if the user pressed space or enter using scanf() ? 回答1: You'll know the user pressed enter because scanf() won't return until the user does so. If you're trying to read