你好,代码如下:
#include
typedef struct cuboid
{
int length;
int width;
int height;
}Cuboid,*cuboid;
int main()
{
Cuboid b={15,10,5};
cuboid p = &b;
printf("长方体的长宽高分别为(通过结构体变量输出):%d,%d,%d\n",b.length,b.width,b.height);
printf("长方体的长宽高分别为(通过指针输出):%d,%d,%d\n",p->length,p->width,p->height);
return 0;
}
运行结果:
#include
typedef struct {
double _width, _height, _length;
} Cuboid;
int main(void) {
Cuboid b, *p = &b;
b._width = 3;
b._length = 4;
b._height = 5;
printf("length = %g, width = %g, height = %g\n", b._length, b._width,
b._height);
p->_width = 3;
p->_length = 4;
p->_height = 5;
printf("length = %g, width = %g, height = %g\n", p->_length, p->_width,
p->_height);
return 0;
}