代碼如下:
#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回圈的控制條件好像不起作用,會報錯

這是為什么
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/100342.html
標籤:C++ 語言
