Quote:Original post by c4c0d3m0n
Going with std:.string would really help you here, it would simplify a lot.
I believe what was left is the stream was '\0', since cin.get() doesn't extract/discard this character (see rip-off's post). So on the next call of cin.get(), it reads from 0 to the next '\0'. Seeing there is still a '\0' left from the last call, cin extracts absolutely nothing.
'\n' (a return character), not '\0' (a null terminator). std::cin doesn't normally ever contain any \0's because there isn't a decent way to type them.
What happens is, cin.get(name, ArSize) reads 'Levistus' into name, adds a '\0' after those 8 characters, and leaves the '\n' on the stream. Then cin.get(dessert, ArSize) sees the '\n' right at the start of the stream, so it does exactly what it is told - reads '' into dessert, adds a '\0' after those 0 characters, and leaves the '\n' on the stream.
Anyway, "following a book" is usually a bad way to learn a language; working with std::string is
easier than all this nonsense, and the fact that your book has you work through any of it (let alone start off with it!) is a sign that it is very much out of date.