I'm starting in C ++, during some tests I noticed that after the second iteration of while the command cin.getline was not read displaying the line after it. I do not understand what happens. Here is the code:
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
using namespace std;
int main(void) {
char matter[20] = " ";
string category(" ");
ofstream write;
bool control = true;
char op = ' ';
while (control) {
cout << "Enter matter: ";
cin.getline(matter, 20);//--------
write.open("database.txt" , ofstream::app);
write << "->" << matter << "\n";
write.close();
cout << "Prosseguir?[Y/N]: ";
cin >> op;
op = toupper(op);
if (op == 'N') {
return 0;
}
}
}
If anyone knows what is ...