Home Segments Index Top Previous Next

515: Mainline

The read function, scanf, reads character sequences only up to the first whitespace character. Occasionally, you find it more convenient to read a whole line of characters using the gets function, where gets is an acronym for get string:

gets (name of character array) 

The gets function reads the characters in the next line that you type and puts those characters into the array, without the end-of-line character, terminating those characters with the null character, \0. Thus, you can put the next line of keyboard input, or redirected input, into the input_buffer array with the following statement:

gets (input_buffer);