I am quite new to c++ so i apologise if this is a simple mistake.
I cannot seem to figure out why my code misses the first word (starts reading from stdin after the first space). There is no bounds checking as i just want to see whats wrong.
cin >> words; gets the first word from the input stream.
Then fgets(words, 60, stdin); gets the next 59 characters from the stream (or until it hits a newline) and overwrites whatever was already in words with that.
So when you enter "Steve is a beginner at C++", then after the cin >> words; call, words will contain "Steve" and the input stream will contain " is a beginner at C++\n".
Then the fgets call will read the " is a beginner at C++\n" part and store that into words, overwriting everything that was already there.
Try replacing those two lines (both the cin >> words; and the fgets(words, 60, stdin);) with cin.getline(words, 60);.
You won't need the #include <cstdio> after that.