プログラム
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line,p1,p2,p3;
ifstream myfile ("infile.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
/*
myfile >> p1 >> p2 >> p3 ;
cout << "p1 : " << p1 << " p2 : " << p2 << " p3 : " << p3 << endl;
*/
getline (myfile,line);
cout << "line : " << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
INFILE.TXT
name
param1 = xyz
param2 = 99
param3
param_abc = 0.1
june 2012
出力
line : name
line : param1 = xyz
line : param2 = 99
line : param3
line : param_abc = 0.1
line : june 2012
line :
param2 を検索して、その値を出力したい、つまり 99