仅供参考我是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;
}
谢谢,它解决了。 – 2013-04-04 19:55:25