C语言结构体

// T4_Struct_115.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "struct.h"


void initializeCoordinate(Coodinate *point);

int _tmain(int argc, _TCHAR* argv[])
{
	/*
	//1.typedef 在结构体创建时使用
	typedef struct Coodinate
	{
		int x; //横坐标
		int y;  //纵坐标

	}Coodinate1;

	//2.typedef 在结构体定义外表声明
	

	//3.struct Coodinate point;//原始状态
	Coodinate1 point;
	point.x = 5;
	point.y = 6;
	
	printf("x:%d;y:%d\n", point.x, point.y);
	// 4.数组元素调用
	Person user; // user是英语“用户”的意思
	printf("您姓什么 ? ");
	scanf_s("%s", &user.lastName,10);
	printf("您名叫什么 ? ");
	scanf_s("%s", &user.firstName,100);
	printf("原来你的名字是 %s%s,失敬失敬\n", user.lastName, user.firstName);

	// 5.定义结构体数组

	ProgrammerLeague point1[10];
	point1[1].x = 0;
	point1[1].y = 0;



	for (int i = 0; i < 10; i++)
	{
		point1[i].x = i;
		point1[i].y = i;
		printf("坐标是:(%d,%d)\n", point1[i].x, point1[i].y);
	}

	


	// 6.结构体变量初始化

	Coodinate point = { 0, 0 };

	Person player = { "", "", "", 0, 0 };

	// 7.结构体指针
	Coodinate *point2 = NULL;
	*/

	// 8.结构体作为函数参数
	
	Coodinate point;
	initializeCoordinate(&point);
	printf("(%d,%d)", point.x, point.y);


	return 0;
}

void initializeCoordinate(Coodinate *point)
{
	point->x = 1;
	point->y = 1;
	

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值