Hi all, new to the forum
Just wanted some assistance: does anyone know why the first word of the string isn't printed in the output when i use 'fgets()' in the code (below) and what can I do to solve this issue?
Thanks in advance.
Output:Code:#include <iostream> #include <cstdio> using namespace std; int main() { char str[40]; // Holds ten characters with a null (0) at the end. cout << "Enter a string: "; cin >> str; //read string from keyboard cout << "Here is your string: " << endl; fgets(str, 40, stdin); cout << str << endl; return 0; }