【发布时间】:2013-07-24 08:06:24
【问题描述】:
如果您有一个包含已知结构文本的文件,您将如何提取某个识别词前面的值?具体来说,如何从下面的文本中提取值。
CDM-nucleon micrOMEGAs amplitudes:
proton: SI -3.443E-10
这是我对脚本的了解程度:
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
string identifier;
double value;
ifstream file("output.txt");
// Commands to extract value
file.close();
return 0;
}
非常感谢。
【问题讨论】:
-
没有人会为您完成这项工作。特别是当您的问题不清楚时。提取什么?识别词是什么?你做了什么,问题出在哪里。搜索 stackoverflow 以了解如何逐行读取文件以及如何使用正则表达式查找位置。这应该会有所帮助。
标签: c++ string output ifstream