求助大佬们一个c++的问题

高桥凉介丶 2020-03-26 01:07:54
代码如下:
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
using namespace std;
int main(){
ifstream is("D://date.txt",ios_base::in);
if(!is){
cerr<<"error";
exit(EXIT_FAILURE);
}
char temp[11];
string rm[12]={"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"};
string t;
int month;
int year;
int day;
while(!is.eof()){
is.getline(temp,11,';');
cout<<temp;
t=temp;
cout<<t;
day=stoi(t.substr(0,2));
month=stoi(t.substr(3,2)) ;
year=stoi(t.substr(6,4));
cout<<year<<" "<<rm[month-1]<<" "<<day<<endl;
}
return 0;
}
date.txt中的内容为01/01/2011;01/02/2012;
我单步调试时,while循环的控制条件好像不起作用,会报错

这是为什么
...全文
81 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
  • 打赏
  • 举报
回复

64,662

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧