#include <iostream>
#include <string>
#include <sstream>
#include<fstream>
using namespace std;
int main()
{
char line[100],inputword[100];
ifstream input;
int count=1;
cin >> inputword;
input.open("text2.txt",ios::in);
while(input.getline(line,100))
{
istringstream iss(line);
string s;
while ( getline( iss, s, ' ')) {
if(s == inputword){
cout << count << " ." << line <<endl;
}
}
count++;
}
return 0;
}
#include <string>
#include <sstream>
#include<fstream>
using namespace std;
int main()
{
char line[100],inputword[100];
ifstream input;
int count=1;
cin >> inputword;
input.open("text2.txt",ios::in);
while(input.getline(line,100))
{
istringstream iss(line);
string s;
while ( getline( iss, s, ' ')) {
if(s == inputword){
cout << count << " ." << line <<endl;
}
}
count++;
}
return 0;
}
Comments
Post a Comment