Help wanted! -- Reply -- Reply
- Posted by Robert Craig <robert_craig at COMPUSERVE.COM> Feb 20, 1997
- 886 views
Ad Rienks writes: > There is still the question: what is returned when you answer the > statement: > input = get(0) with a single <ENTER>. > It looks like nothing is returned. Maybe get(0) should be replaced by ... get(0) keeps reading from standard input (the keyboard) until it has some non-"whitespace" to deal with. i.e. it ignores blanks, tabs and the Enter key, looking for digits or other characters. You can hit Enter as many times as you like, but get(0) won't be satisfied until you really type something. It sounds like you should call gets(0), and then feed the resulting string into value(). e.g. input = value(gets(0)) gets(0) will read exactly one line of input. value() returns the same error codes as get(). In this way you will see a GET_EOF error code if the person just hits Enter, a GET_FAIL if the number is badly formed, and a GET_SUCCESS for a valid number. [Note that the user could also type a string like "ABCDEF", or a numeric sequence like {1,2,3} and value() would handle that too.] Regards, Rob Craig Rapid Deployment Software