May 15, 2015 at 1:05pm UTC
Dear All,
I would like to use a code to extract some lines in binary file and send the result to a ini file. when I try with this code and use a simple word "param" I don't get any thing
I would like your help
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
bool isWanted(const std::string & line);
int main()
{
ifstream fin("Test.txt");
string line;
while (getline(fin, line))
{
if (isWanted(line))
cout << line << endl;
}
return 0;
}
bool isWanted(const std::string & line)
{
// any selection criteria you like
return (line.find("two") != string::npos);
}
May 15, 2015 at 1:14pm UTC
First of all, please wrap your code in the code tags.
Secondly, you are not testing that your ifstream is in fact open: Use fin.bad(), etc.
Thirdly, what does your input data look like?