i wanna read a file .txt and show wich lines have the word searched for what should i add to my program?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <iostream>
#include <fstream>
#include <ostream>
#include <conio.h>
using namespace std;
int main()
{
char a;
a='a';
ofstream danainkare;
danainkare.open("file.txt",ios::out | ios::app);
cout<<"DVD or CD?"<<endl;
while(a!=13)
{
a=getch();
cout<<a;
danainkare<<a;
}
danainkare<<"-";
a='a';
cout<<"please write the authors name:"<<endl;
danainkare<<"author:";
while(a!=13)
{
a=getch();
cout<<a;
danainkare<<a;
}
danainkare<<"-";
a='a';
cout<<"please write genre:"<<endl;
danainkare<<"genre:";
while(a!=13)
{
a=getch();
cout<<a;
danainkare<<a;
}
danainkare<<"-";
a='a';
cout<<"please write the year of release:"<<endl;
danainkare<<"year:";
while(a!=13)
{
a=getch();
cout<<a;
danainkare<<a;
}
danainkare<<endl;
cout<<"if you wanna retrieve type yes if not just press the enter button";
a='a';
int i=0;
while(a!=13)
{
a=getch();
if(a=='y')
i++;
if(a=='e')
i++;
if(a=='s')
i++;
}
if(i==3)
{
cout<<"type the author you wanna search";
}
}
return 0;
}
|
Last edited on