结构体struct知识
2022-10-12 08:52:03
// 结构体知识
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
#include<string.h>//strcpy-字符串拷贝-库函数-<string.h>
//结构体-我们自己创建出来的一个类型
//例如:要描述一本书需要:书名+作者+出版社+书号
//struct person {//结构体struct描述一个人
// char sex[6],name[20],interest[20];
// int age;
// double height, weight;
//};
//int main() {
// struct person a = { "男","it陌辰","写代码",17,178,72};
// struct person* p = &a;
// printf("性别:%s\n名字;%s\n兴趣爱好:%s\n年龄:%d\n身高:%.2fcm\n体重:%.2fkg",p->sex,p->name,p->interest,p->age,p->height,p->weight);
//}
//struct book {//创建一个结构体类型
// char name[200];//C语言程序设计
// int price;//55
// char from[100];//二次元陌辰工作室
//};
//int main() {//利用结构体类型-创建一个结构体类型的变量
// struct book a = { "C语言程序设计",55,"二次元陌辰工作室" };//定义一个a来存放结构
// strcpy(a.name, "跟着董某人从0到1学JAVA");//strcpy - string copy - 字符串拷贝-库函数-<string.h>
// struct book* p = &a;
// //printf("%s\n%d\n\t",( * p).name,(*p).price);//有点麻烦
// //printf("书名:%s\n\t价格:%d元\n",a.name,a.price);
// //. 结构体变量.成员
// //-> 结构体指针->成员
// printf("书名:%s\n价格:%d元\n出版社:%s", p->name, p->price, p->from);//建议用箭头->,方便快捷
// return 0;
//}
//int main()//指针变量的使用
//{
// int a = 10;
// int* p = &a;//32-4 64-8
// *p=20;
// printf("%d,%d",*p,sizeof(p));
// return 0;
//}
最新文章
- js中数组遍历for与for in区别(强烈建议不要使用for in遍历数组)
- JDK1.5新特性
- 02/07/2106 @ 6:28am (UTC)
- Power Map 入门
- iOS开发--应用程序上线
- NSArray和NSMutableArray的详解
- winphone 开发学习笔记(2)
- JQuery图片轮换 nivoSlider图片轮换
- 真正的手机破解wifi密码,aircrack-ng,reaver,仅限mx2(BCM4330芯片)
- linux c中select使用技巧
- 2016";百度之星"; - 资格赛(Astar Round1) Problem D
- Django 学习笔记(二)
- JPush简单Java服务端案例实现
- 全志A33开发板的安卓控制LED-2-JNI基础
- 【转】设置 vim 显示行号永久有效
- 如何将maven的jar项目简单快速的转变成war项目
- linux因勿删或误操作导致登录界面异常,命令无法使用,显示/bin/bash:No such file or directory
- hdu 5099 简单模拟(比较型号)
- 自定义 iPhone 铃声
- Datatable数据分组
热门文章
- 2500-使用MyBatis操作MySQL进行批量更新的注意事项
- html的基础01
- Spring 常见面试题总结 | JavaGuide
- 基于微前端qiankun的多页签缓存方案实践
- C#里如何简单的校验时间格式
- CentOS7桥接模式上不了外网的配置
- 6.13 NOI 模拟
- linux-0.11分析:boot文件 head.s 第三篇随笔
- React报错之`value`&#160;prop on&#160;`input`&#160;should not be null
- 如何实现 System.out.println(";a";) 显示 b