Niki37
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Помогите пожалуйста еще раз , написал программу для ввода и вывода информации из файла"file.txt" попытался добавить поиск т.е. ввожу название авто , имя , цвет , номер и вывожу только те данные которые мне нужны , например ввожу : Audi||Vova||Red||123 Volga||Sasha||yellow||1111 А хочу вывести на экран только по запросу "Audi" : Audi||Vova||Red||123 без Volga||Sasha||yellow||1111 Помогите пожалуйста! #include<iostream> #include<fstream> #include<conio.h> using namespace std; int main() { for(int e=0;e<100;e++){ ofstream f ("file.txt"); for (int i=0;i<10;i++){ string a; string name; string col; string num; char y=('||'); cout<<"Please enter auto: "; cin>>a; if(a =="stop")goto start; cout<<"Please enter name: "; cin>>name; cout<<"Please enter color: "; cin>>col; cout<<"Please enter number: "; cin>>num; f<<a<<y<<name<<y<<col<<y<<num<<endl; } } start: cout<<"----------------------"<<endl; cout<<"Auto|Name|Color|Number"<<endl; cout<<"----------------------"<<endl; fstream f("file.txt"); const char n=10; string q[n]; for(int e=0;e<n;e++) f>>q[e]; string x; cout<<"Enter X: "; cin>>x; for(int e=0;e<n;e++){ if (x==q[e]) cout<<"Reseach"<<x<<"lialialia"<<e; else cout<<"error!"; } getch(); } |