求VC达人帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/23 04:58:32
在文件code.txt中记录这样一系列数据,“中:125879466”
我希望这样读取数据,汉字存入字符串中,“:”略过,后面的数字以单个数字的形式读取,存入int a中,,,,求高手帮忙。。

#include <iostream>
#include <string>
using namespace std;

int main()
{
string a;
int b;
getline(cin,a,':'); //读到 : 以前的保存在字符串a中 并过滤 :
cin>>b; //以后的数据保存在b中
cout<<a<<endl<<b<<endl;
return 0;
}

只是给你提供一个思路,代码需要你自己写 C++的代码