Code:
fgets ( char * str, int num, FILE * stream );
// | | |
// | | This is where you want to read the
// | | string from. If you want to get it
// | | from the user, the argument should be
// | | the standard input stream (stdin).
// | |
// | This restricts the length of the string read,
// | and only allows "num-1" characters to be read.
// | Any characters beyond the limit are not taken
// | from the input stream. This argument is the
// | reason why "fgets()" is strongly recommended;
// | the old "gets()" function has no such limitation,
// | and will happily read characters from the stream
// | even if it overflows the buffer where the string
// | is to be stored. This could cause errors in the
// | program, and can also be a security vulnerability.
// |
// This is the destination, where you want to put the string when
// it is read. For your purposes, this will likely be a character
// array (i.e. "charArray[50]"). You can simply pass the name of the
// array (i.e. "charArray"), as in this case, the name of the array
// will behave as a pointer to the first element of that array.