使用结构类型碰到的问题(学生信息)
程序代码:
#include "stdafx.h"
#include<iomanip.h>
struct student
{float num;char name[10];char sexy; int age;};
struct student stu;
int main(int argc, char* argv[])
{student stu={200601,"大军",'男',21};//学号的开头数字不能为0
cout<<setw(10)<<stu.num<<setw(10)<<stu.name<<setw(5)<<stu.sexy<<setw(5)<<stu.age<<endl;
cin>>argc;
return 0;
}
这段程序运行结果为: 200601 大军 ? 21我想问的是:如何才能显示"男"?还有"num"的赋值为什么不能以"0"开头(我试过了,如果以0字开头,就会出错“c:\documents and settings\admini
strator\my documents\c++\结构体\结构体.cpp(11) : error C2041: illegal digit '8' for base '8'")?这是为什么?希望大家能帮忙解决








