I'm new to c++ and have a question about a seeming inconsitency I've found in one of my books.
When taking string input from the keyboard for structures, the examples in my book use the sizeof operator like so:
cin.getline(Mystruct.name, sizeof(Mystruct.name) - 1);
The '-1' is used to allow room for the terminating null character.
Now, I have skipped forward a little in my book so I can add some file I/O to my practice programs.
However, the I/O examples (using the fstream class) do not subtract 1 from the char array when reading from a file. Why is this? Does this class automatically stop reading 1 byte early, or is this a typo?