仅供参考,我是 C++ 的初学者。这只是完整代码的一部分,问题是'student.id',如果输入以'0'开头,例如'06042010',输出显示不为零(在这种情况下是'6042010'!而关键是,我希望显示第一个零。谢谢。
#include<iostream>
using namespace std;
struct students
{
char name[15];
char surname[10];
int id;
};
int main()
{
students student;
cout<<"Name: ";
cin>>student.name;
cout<<"Surname: ";
cin>>student.surname;
cout<<"ID: ";
cin>>student.id;
cout<<"\nStudent: "<<student.name<<" "<<student.surname<<" ID "<<student.id<<endl;
return 0;
}