【发布时间】:2017-04-05 01:29:48
【问题描述】:
所以我正在处理的部分任务是我必须弄清楚居民是否足够大到可以退休。我正在从文件中获取字符串,现在我只需要找到年份。问题是,我不知道该怎么做。
这是目前为止的代码
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
ifstream oldretire;
string names;
oldretire.open("oldretirement.txt");
getline(oldretire, names);
names find(
}
这是一个示例字符串
马修·艾伦·阿贝雷格 1963 年 452,627
我想我需要使用 find 函数来查找一个带有空格、四个字符、然后是另一个空格的字符串。但后来奥兰会被发现。
任何帮助将不胜感激!
【问题讨论】:
-
您确定
Matthew Alan Aberegg 1963 452,627在一行中吗?如果是,那么您可以读取一行并用空格分隔。