帮忙看下这个程序
程序代码://********对学生数据的初始化(类的构造函数)**********//
student::student()
{
//用for循环对全部数组中的数据初始化
for(int i=0;i <100;i++)
{
ob[i].id =0;
ob[i].sex =' ';
ob[i].name =NULL;
ob[i].address=' ';
ob[i].date=' ';
ob[i].cons=' ';
ob[i].ps=' ';
}
this->stulen =0;
}
//********输入学生的数据,并判断是否在规定数据域内*******//
void stuatom::setup()
{
char n[20];
char ad;
char da;
char cs;
char ss;
char s;
int b;
do
{
cout<<" 学号(1001与1010之间): ";
cin>>b;
if(b>1010||b <1001)
cout<<" 数据有误!!重新输入.."<<endl<<endl; else break;
}while (b <1010||b>1001);
id=b;
do
{
name=new char[strlen(n)+1];
cout<<" 姓名: ";
cin>>n;
}while ( strlen(n)>6 && strlen(n) <4 );
strcpy(name,n);
cout<<" 性别(m/f):" ;
cin>>s;
//如果输入性别在数据域内,跳出循环并且赋值。
//如果不在数据域内,一直循环到输入数据符合数据域为止
while (s!='m' && s!='f')
{
cout<<" 数据有误!!重新输入.."<<endl<<endl;
cout<<" 性别(m/f):";
cin>>s;
}
sex=s;
cout<<" 工作部门(0-20): ";
cin>>ad;
while (sizeof(ad) <0 || sizeof(ad)>20)
{
cout<<" 数据有误!!重新输入.."<<endl<<endl;
cout<<" 工作部门(0-20): ";
cin>>ad;
}
address=ad;
_getch();
cout<<" 工作日期(0-10): ";
cin>>da;
while (sizeof(da) <0 || sizeof(da)>10)
{
cout<<" 数据有误!!重新输入.."<<endl<<endl;
cout<<" 工作日期(0-10): ";
cin>>da;
}
date=da;
_getch();
cout<<" 工作内容(0-20): ";
cin>>cs;
while (sizeof(cs) <0 || sizeof(cs)>20)
{
cout<<" 数据有误!!重新输入.."<<endl<<endl;
cout<<" 工作内容(0-20): ";
cin>>cs;
}
cons=cs;
_getch();
cout<<" 备注(0-20): ";
cin>>ss;
while (sizeof(ss) <0 || sizeof(ss)>20)
{
cout<<" 数据有误!!重新输入.."<<endl<<endl;
cout<<" 备注(0-20): ";
cin>>ss;
}
ps=ss;
_getch();
}为什么在输入地点 日期 内容和备注的时候
只能有单字符?
哪位 帮忙改一改?
感激不尽~









