This question has already been answered:
void read_character(ifstream &a) { char t; a >> t; if (t == '+') { string temp; getline(a, temp); character_name = temp; a >> number; spetifications = new string[number]; spetifications_value = new int[number]; for (int i = 0; i < number; i++) { a >> spetifications[i]; } for (int i = 0; i < number; i++) { a >> spetifications_value[i]; } a >> t; if (t != '+') { throw; } } else { throw; } } int main() { ifstream k("output.txt"); b.read_character(k); }
The essence of the problem is as follows: I want to read object b from a text file, for convenience, the block of this object is highlighted with pluses. There are no exceptions, even the last plus is fully read, but everything after getline () is read incorrectly with the left values, and other objects subsequently throw out exceptions when reading. The text file itself:
+ void 2 first_spetification second_spetification 45 100 +
getline
everywhere to read (numbers come from the lines already read) - avp 8:31 pm