劳驾看一下这个问题,很奇怪
#include "stdafx.h"#include <iostream.h>
#include <string.h>
struct
{
int year,month,day;
}myDate;
int main()
{
char input[80],yearStr[5],monthStr[3],dayStr[3];
cout<<"请输入xxxx年xx月xx日:";
cin.getline(input,80);
for (int i=0;i<=3;i++)
{
if (input[i]>='0'&&input[i]<='9')
yearStr[i]=input[i];
else break;
}
yearStr[i]='\0';
i=i+1;
for(int j=0;j<=2;j++,i++)
{
if (input[i]>='0'&&input[i]<='9')
monthStr[j]=input[i];
else break;
}
monthStr[i]='\0';
i=i+1;
for(int m=0;m<=2;m++,i++)
{
if (input[i]>='0'&&input[i]<='9')
dayStr[m]=input[i];
else break;
}
dayStr[i]='\0';
cout<<input<<endl
<<yearStr<<endl
<<monthStr<<endl
<<dayStr<<endl;
}
可以编译,在VC++里,但是得不出正确结果.