C结构大小计算:struct stu{int No;char name[10];char sex;int age;}s1
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/18 03:04:32
C结构大小计算:
struct stu
{
int No;
char name[10];
char sex;
int age;
}s1;
int (4byte)+char(1*10byte)+char(1byte)+int(4byte)=19byte.但是结构体的总大小为结构体最宽基本类型成员大小的整数.当前最宽为int(4byte).计算出来是19byte,实际为20byte.
struct stu
{
int No;
char name[10];
char sex;
int age;
}s1;
int (4byte)+char(1*10byte)+char(1byte)+int(4byte)=19byte.但是结构体的总大小为结构体最宽基本类型成员大小的整数.当前最宽为int(4byte).计算出来是19byte,实际为20byte.
其实这个是编译器的问题,其实编译器问题,这个是实现原理有关.如果不满足一定的字节,将会自动填充.如何解决这个问题呢?使用Progrma 1;就行了.当然了这只是一个C、C++代码.
#include struct student { long num; char name[10]; int age;
A.若有以下说明和语句:struct stu { int no; char *name; }student,*p=&st
请问这个结构体所占的空间大小是___字节.typedef struct { int a,char b,short c,s
struct student{int num;char name[20];}stu1;stu1.name="Li Min
一个C语言找错题#includemain(){struct{long number;char name[10];char
typedef union { long i;int k[5];char c; }DATE; struct date {
struct{int i;char c;float a}test;则sizeof(test)的值是
11.有如下定义:struct{ int x; char *y;
设有定义语句“struct {int a;float b;char c;}abc,*p;”,则对结构体成员a的引用可以是
对于以下结构定义:struct{ int len; char str;} s,*p=&s; p->str的意思是?
(1/2)已知有如下声明,则sizeof(test)的值是_____?struct {int i; char c; fl
#include #include void fun(char *w,int n) { char t,*s1,*s2;