3.2. Gets() and puts() functions

 

The char *gets(char *s) function reads a line from stdin into the buffer pointed to by s until either a terminating newline (‘\n’)or EOF (End of File). *s means a pointer.

The int puts(const char *s) function writes the string ‘s’ and ‘a’ trailing newline to stdout.

Example

#include <stdio.h>
int main( ) 
{
   char str[100];
   printf( "Enter a value :");
   gets(str);
   printf( "\nYou entered: ");
   puts(str);
   return 0;
}

NOTE! This chapter does not include exercises but this information will be tested in quizzes 3-4! It is very important that the student will make all examples shown in this chapter.