我有一个文件,其中包含蛋白质坐标以及它之前的其他信息。我的目标是查找名为“$PARAMETERS”的特定行,然后从那里复制它之后的每一行,直到文件末尾。
我怎样才能做到这一点?这是我编写的整个程序的一部分的小代码(几年前别人写的,我接手升级他的代码以进行研究):
ifstream InFile;
InFile.open (DC_InFile.c_str(), ios::in);
while ( not InFile.eof() )
{
Line = NextLine (&InFile);
if (Line.find ("#") == 0) continue; // skip lines starting with # (comments)
if (Line.length() == 0) continue; // skip empty lines
size_t pos = Line.find("$PARAMETERS");
Line.copy(Line.begin("$PARAMETERS")+pos, Line.end("$END"));
&Line.copy >> x_1 >> y_2 >> z_3;
}
请记住,我将 Line 定义为string