结构体类型在定义变量时,其前可以省略

来源:互联网 发布:苹果mac常用软件 编辑:程序博客网 时间:2024/06/05 02:28


/*结构体类型在定义变量时,其前struct可以省略 */
#include<iostream>
using namespace std;
struct student
{
int no;
float math;
};//别忘记分号
int main()
{
int n;
cin>>n;
student wang;//C语言中,必须struct student wang; 
wang.no=n;
cin>>wang.math;
cout<<wang.no<<" "<<wang.math<<endl;
return 0;

}


0 0
原创粉丝点击