c - How can I detect a space or newline at the end of scanf()? -


i'm writing program have accept commands user shell user can set values environment variables. problem i'm having if user types set var var-value need know user typed space instead of set , pressed enter different command. how can determine if user pressed space or enter using scanf()?

you'll know user pressed enter because scanf() won't return until user so. if you're trying read characters in real time user types, scanf() not work you. need use getchar(), getch() or getche() functions, or function provided os reading keyboard input. read characters 1 one array, scanning spaces , enter key read.

see this question.


Comments

Popular posts from this blog

mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -

c# - Pausing a storyboard on TabItem mouse over -

c# - Attribute value in root node of xml Linq to XML -