I have a problem when comparing user input to text file line, it goes all right until when i want to output that all line, it only outputs remaining part of the line, when finding match. This is small part of airport project that i need to finish for school, but i keep strugling on this problem! So i hope someone can help me. Text file is this
- LATVIJA/RIGA | BOEING-45 | RIGA - MASKAVA | 20.02.2018 / 15:55 | R-126 |
- LATVIJA/RIGA | BOEING-45 | RIGA - HELSINKI | 25.02.2018 / 15:55 | R-127 |
- LATVIJA/RIGA | BOEING-45 | RIGA - AMERIKA | 20.02.2018 / 15:55 | R-129 |
- LATVIJA/RIGA | BOEING-45 | RIGA - BERLINE | 20.02.2018 / 15:55 | R-134 |
- LATVIJA/RIGA | BOEING-45 | RIGA - MASKAVA | 25.02.2018 / 15:55 | R-166 |
Bold text is what it outputs as you can see in this image
but i need it to output these text lines like this when i input date 20.02.2018
- LATVIJA/RIGA | BOEING-45 | RIGA - MASKAVA | 20.02.2018 / 15:55 | R-126 |
- LATVIJA/RIGA | BOEING-45 | RIGA - AMERIKA | 20.02.2018 / 15:55 | R-129 |
- LATVIJA/RIGA | BOEING-45 | RIGA - BERLINE | 20.02.2018 / 15:55 | R-134 |
Heres the code
ifstream myfile;
myfile.open("statistika.txt", ios::app);
string datums;
string item;
string teksts;
cout <<"Ievadi velamo lidosanas datumu: " << endl;
cin >> datums;
while(!myfile.eof()){
myfile >> item;
if(item==datums){
getline(myfile, teksts);
cout << teksts <<endl;
}
}