In C language has been very easy to confuse, get and fgets the difference:
char * fgets (char * str, int num, FILE * stream);
Reads characters from stream and stores them as a C string to str until (num-1) characters ha ve been read or either a newline or the end-of-file is reached, whichever happens first.
A newline character makes fgets stop reading, but it's considered a valid character by the function and included The string copied to str.
A terminating null character is automatically appended after the characters copied to str.
Notice that fgets was quite different from Gets:not only fgets accepts a stream argument, but Also allows to specify the maximum a size of str and includes in the string any ending newline character.
char * gets (char * str);
Get string from stdin
Reads characters from the standard input (stdin) and stores them as a C string to str until a newline Character or theEnd-of-file is reached.
The newline character, if found, is isn't copied into str.
A terminating null character is automatically appended after the characters copied to str.
Notice that 's quite different from Fgets:not only gets uses stdin as source, but it does not incl Ude the ending newline character in the resulting string and does don't allow to specify a maximum size for str (WH Ich can leads to buffer overflows).
In short, fgets is able to specify the maximum number of input characters (num-1), and they all terminate after encountering a newline character, Fgets also reads the newline character into the string, and gets a simple drop-line character.
There are four functions in C + + that correspond to CIN:
IStream & Get (char *, int, char);
IStream & Get (char *, int);
IStream & Getline (char *, int, char);
IStream & Getline (char *, int);
Here, both get and getline do not read the newline character, but get will leave the newline character (or the other delimiter specified) in the stream, and Getline will read the newline character from the stream and discard it.
Row reads in c/A + +