<b>get_string()</b>




Document: The safe-c User Guide

next assign_string()
up Functions
gif put_string()

get_string()

get_string() accepts exactly one argument which must be of string_type, and must be a variable.

get_string() reads, or inputs, a string from the standard input stream, or stdin for short, and stores it in the string variable given as an argument. Exactly one line is read - that is, reading of the string is terminated when a newline character is encountered.

By default, stdin simply corresponds to the keyboard. Whatever characters are typed in are also echoed in the MS-DOS window in which the program is being executed; pressing the Enter key generates the newline character which terminates reading.

Alternatively, when the program is being started, stdin can be redirected to read from a file on disk. Suppose the executable program is called foo.exe; then the following way of executing the program under DOS would result in stdin being redirected to read from a file called input.txt:

    D:\SOFTENG1>foo <input.txt

get_string() produces a return value of boolean_type. This will normally be the value TRUE indicating that a string has been successfully read. However, if, for some reason, a string cannot be read, the value FALSE will be produced instead. The usual reason why this might arise would be that stdin has been redirected to come from a disk file, and the end of the file is encountered - naturally, in that case, get_string cannot actually read in a further string.




Document: The safe-c User Guide

next assign_string()
up Functions
gif put_string()



McMullin@eeng.dcu.ie
Fri Jan 12 12:30:02 GMT 1996