0
I’ve been trying to make a program to which you search for several strings in a . txt in the c++ language but can only search for one string
My code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream input;
size_t pos;
string line;
input.open("t.txt");
if(input.is_open())
{
while(getline(input,line))
{
pos = line.find("hey");
if(pos!=string::npos) // string::npos is returned if string is not found
{
cout <<"Found!";
break;
}
}
}
thanks, helped me a lot, I’m learning more and more about programming in this wonderful forum - Noob Zando
– Noob Zando