读取文件 lhc.txt, 内容如下:
zhongguo 1 2 3 4 chinese
#include<iostream>
#include<sstream>#include<string>
#include<fstream>
int main()
{
std::string filename = "lhc.txt";
std::ifstream infile( filename.c_str() );
std::string str1, str2 ;
int a[4];
std::string lineStr;
std::stringstream ss;
while ( std::getline(infile,lineStr) )
{
ss << lineStr;
ss >> str1;
for(int i=0; i<4; i++ )
ss >> a[i];
ss >> str2;
}
std::cout << " str1 is " << str1 << " str2 is " << str2 << std::endl;
for (i