struct tag_1{
struct tag_1 A; /* 结构体 */
int value;
};
struct tag_1{
struct tag_1 *A; /* 指针 */
int value;
};
typedef struct {
int value;
NODE *link; /* 虽然也使用指针,但这里的问题是:NODE尚未被定义 */
} NODE;
/* 方法一 */
typedef struct tag_1{
int value;
struct tag_1 *link;
} NODE;
/* 方法二 */
struct tag_2;
typedef struct tag_2 NODE;
struct tag_2{
int value;
NODE *link;
};
/* 方法三 */
struct tag_3{
int value;
struct tag *link;
};
typedef struct tag_3 NODE;
typedef struct tag_a{
int value;
B *bp; /* 类型B还没有被定义 */
} A;
typedef struct tag_b{
int value;
A *ap;
} B;
/* 方法一 */
struct tag_a{
struct tag_b *bp; /* 这里struct tag_b 还没有定义,但编译器可以接受 */
int value;
};
struct tag_b{
struct tag_a *ap;
int value;
};
typedef struct tag_a A;
typedef struct tag_b B;
/* 方法二 */
struct tag_a; /* 使用结构体的不完整声明(incomplete declaration) */
struct tag_b;
typedef struct tag_a A;
typedef struct tag_b B;
struct tag_a{
struct tag_b *bp; /* 这里struct tag_b 还没有定义,但编译器可以接受 */
int value;
};
struct tag_b{
struct tag_a *ap;
int value;
};
#include <stdio.h>
struct Point
{
double x; /*x坐标*/
double y; /*y坐标*/
double z; /*z坐标*/
};
int main()
{
struct Point oPoint1={100,100,0};
struct Point oPoint2;
struct Point *pPoint; /*定义结构体指针变量*/
pPoint=& oPoint2; /*结构体指针变量赋值*/
(*pPoint).x= oPoint1.x;
(*pPoint).y= oPoint1.y;
(*pPoint).z= oPoint1.z;
printf("oPoint2={%7.2f,%7.2f,%7.2f}",oPoint2.x, oPoint2.y, oPoint2.z);
return(0);
}
oPoint2={ 100.00,100.00,0.00}
…… (*pPoint).x= oPoint1.x; (*pPoint).y= oPoint1.y; (*pPoint).z= oPoint1.z; ……
…… pPoint->x= oPoint1.x; pPoint->y= oPoint1.y; pPoint->z= oPoint1.z; ……
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有