Untitled
unknown
c_cpp
a year ago
597 B
8
Indexable
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream inputFile("wiersz.txt");
if (!inputFile.is_open())
{
cerr << "Nie mozna otworzyc pliku dane.txt!" << endl;
return -1;
}
else
{
string word;
cout << "Podaj slowo do wyszukania: ";
getline(cin, word);
cout << "\n\nWiersze tekstu ze slowem " << word << ":\n";
string line;
while (getline(inputFile, line))
{
if (line.find(word) != std::string::npos)
{
cout << line << endl;
}
}
inputFile.close();
}
return 0;
}
Editor is loading...
Leave a Comment