乗り"Run-Time Check Failure #2 - Stack around the variable 'id' was corrupted."
ますwhile condition
。わからない!このエラーの原因は何ですか?
void Term::set_id()
{
char id[Term::ID_LENGTH];
do
{
cout << "\n\nEnter the term id(like 90911): ";
cin >> id;
}while(valid_id(id) != true);
}
bool Term::valid_id(char *id)
{
//counting how many chars id has got:
int n=0;
for(char* str=id; *(str+n)!=0; n++);
if(n!=Term::ID_LENGTH)
return false;
//checking that id consist of digits only
int i=0;
for( char* str=id; (*(str+i)>=48 && *(str+i)<=57) && i<Term::ID_LENGTH; i++);
if(i<Term::ID_LENGTH)
return false;
int fy= (*(id) - 48) * 10 + (*(id+1) - 48);//former year
int ly= (*(id+2) - 48) * 10 + (*(id+3) - 48);//latter year
int t= *(id+4) - 48;//term number
if(ly - fy != 1)//any difference other than 1
return false;
if(!(t==1 || t==2 || t==0))//t==0 is for summer term
return false;
return true;
}