怎样从一个字符串里面读出多个整数来?内有详细说明。
一个字符串 buf="4 4 3 2 0"
第一个4表示为后面有4个整数,5个数用多个空格分开。请问怎样读到数组中去呢?
字符串以换行结束。
要用标准c语言写。
还想问有从文件里面读一个整数的c语言函数吗?
谢谢了
问题点数:0、回复次数:1Top
1 楼edtaylcamel(啊磊)回复于 2003-06-01 09:23:43 得分 0
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main()
{
string buf="4 4 3 2 0";
vector<string>result;
stringstream s(buf);
string data;
while(getline(s, data, ""))
result.push_back(date);
cout<<"5"<<result[5]<<"4"<<result[4]<<"3"<<result[3]<<<...<endl;
system("pause");
return 0;
}
我也见过的问题,切磋一下。。Top




