You have to consume the entire first line before reading in the second one.

BTW:
The following has nothing to do with your problem:
1. You're mixing C stdio with C++ iostreams. This may confuse your IO because both systems use different IO buffers. See http://www.cplusplus.com/reference/ios/ios_base/sync_with_stdio/ for help or better: Only use one of those systems.
2. You want to write a function to read in your character arrays to avoid writing the same code multiple times (line 16-26 and 28-38).