标题:请假sizeof问题
取消只看楼主
youtk21ai
Rank: 1
等 级:新手上路
帖 子:13
专家分:5
注 册:2010-4-8
结帖率:80%
已结贴  问题点数:10 回复次数:0 
请假sizeof问题
#include "iostream.h"
#include "iomanip.h"

struct  student
{
    char id[10];
    char name[20];
    char sex;
    int age;
    char department[30];
    float score;
};

void main(){
    student student1 = {"05030100","WangWei",'M',20,"Computer",95},
        student2 = {"05030101","LiMing",'M',21,"Physic",98};
    float average;
    cout<<student1.age<<" "<<student1.department<<" "<<student1.id<<" "<<student1.name<<" "<<student1.score<<" "<<student1.sex<<endl;
    cout<<student2.age<<" "<<student2.department<<" "<<student2.id<<" "<<student2.name<<" "<<student2.score<<" "<<student2.sex<<endl;
    average = (student1.score+student2.score)/2;
    cout<<"average="<<average;
    cout<<"sizeofstudent1="<<sizeof(student1)<<endl;
}

为什么sizeof(student1)=72?
搜索更多相关主题的帖子: sizeof 请假 
2010-06-06 03:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-309344-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.202645 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved