The positioning in the text files has already been written in the commentary - https://ru.stackoverflow.com/users/182825/ant ♪ Anyway, your challenges. fseek They're putting a position in the file just at the beginning or the end, and it's going to be all right here https://msdn.microsoft.com/ru-ru/library/75yw9bf3.aspx : Properly searching 0 relative to any origin) In addition to one challenge:fseek(file, 8, SEEK_END);
You're trying to get out of the file, 8 bytes further than it ends. This is not prohibited in principle (see above). https://msdn.microsoft.com/ru-ru/library/75yw9bf3.aspx but empty places will be filled with zeros. Is that exactly what you want to behave?if (file == NULL) {
fclose(file);
Don't close. not open file. That's what it says. https://msdn.microsoft.com/ru-ru/library/fxfsw25t.aspx :Fclose's function is closing the stream. If the stream parameter is NULL, the inadmissible parameter shall be produced as described in the parameter verification section. If performance can continue, fclose sets errno in EINVAL and returns EOF. It is recommended that the stream indicator be always checked before the function is challenged. file = fopen(filename, "w");
fclose(file);
file = fopen(filename, "r");
Here you create an empty file and open it for reading. What can I read? file = fopen(filename, "w");
fclose(file);
file = fopen(filename, "r+");
There's an empty file here, then it opens for recording and reading. But it's a challenge to make-- file = fopen(filename, "w+");
(See. https://msdn.microsoft.com/ru-ru/library/yeby3zcb.aspx )