String Input/ Output Functions


String Input/ Output Functions :

The gets() and puts() functions enables us to read and write strings of characters at the console .

The gets() function reads a string of characters entered at the keyboard and places them at the address pointed to by its character pointer argument.

The character can be typed at the keyboard until a carriage return is struck. The carriage return does not become the part of the string , instead  null terminator is placed at the end.

The gets() function unlike scanf() can read strings with spaces also.
gets() cannot be used to return a carriage return . any typing mistakes can be corrected by using the BACKSPACE key before pressing ENTER.

Example program :
gets()


Output:
gets()


The puts() function writes its string argument to the standard output followed by newline.

The puts() recognizes escape sequences such as ‘\t’ , ‘\b’ ,etc.
The puts() function returns EOF if an error occurs .otherwise it returns a non zero value.

Example program:
puts()


Output:
puts()


Thank you …  

Previous Post
Next Post
Related Posts

0 comments:

Popular Posts