64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;
int main()
{
stringstream oss("Step Time XX0001 XX0008 XX0009 XX0010 \n"
"1 2 3 4 5 6 \n"
"1 2 3 4 5 6 \n"
"1 2 3 4 5 6 \n"
"1 2 3 4 5 6 \n"
"1 2 3 4 5 6 \n"
);
string Title; // 标题行
int step; // 步数
double data[5]; // 装载数据
int cnt = 0; // 数据计数
while (getline(oss, Title) && (Title.find("Step") != string::npos))
; // 跳过开头标题
while (oss) { // 读取一行数据
oss >> step;
oss >> data[0] >> data[1] >> data[2]
>> data[3] >> data[4] ;
cnt++;
}
// 测试一行
cout << data[0] << data[1] << data[2]
<< data[3] << data[4] ;
return 0;
}
// readfile.cpp
#include <wx/textfile.h>
int main(int argc, char **argv)
{
wxTextFile file(wxT("test.c"));
file.Open();
wxPrintf(wxT("Number of lines: %d\n"), file.GetLineCount());
wxPrintf(wxT("First line: %s\n"), file.GetFirstLine().c_str());
wxPrintf(wxT("Last line: %s\n"), file.GetLastLine().c_str());
wxPuts(wxT("-------------------------------------"));
wxString s;
for ( s = file.GetFirstLine(); !file.Eof();
s = file.GetNextLine() )
{
wxPuts(s);
}
file.Close();
}
Output
Number of lines: 8
First line: #include
Last line: }
-------------------------------------
#include <glib.h>
#include <glib/gstdio.h>
int main() {
g_mkdir("/home/vronskij/test", S_IRWXU);
}