Chances are that the question is not that: the file content is more likely to be
"I love computer\r\n"
which is very different.
But this is your homework: so it's your task.
Start by looking at the definition of
fgets
:
fgets - C++ Reference[
^] and it's obvious that what you get will depend on the parameters you pass to it - the count is significant. If the count is 3, you will get four characters stored in the buffer: 'I', ' ', 'l', and '\0' - the last being a null terminator to mark the end of the string. Other values will give you other results...
Try it: look at the question, set up the file, and write the code to do it, and use the debugger to find out exactly what happens. This isn't complicated!