摘要: print("********如何实现switch-case********") local switch = { [1] = function() print ("case1") end, [2] = function() print ("case2") end, [3] = function() 阅读全文
posted @ 2020-11-24 00:30 Axuanup 阅读(3489) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> #include<string.h> //使用匿名结构体嵌套 struct person1 { const char* name; char gender[20]; struct { int age; }; }p1; //不使用匿名结构体嵌套 struct pho 阅读全文
posted @ 2020-04-06 20:17 Axuanup 阅读(890) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> #include<string.h> /* struct 类型名 { 类型 变量名; 类型 变量名; }tpye_name1,tepy_name2; //tpye_name1,tepy_name2为具体变量名,使用时无需再声明结构体了 */ struct Game 阅读全文
posted @ 2020-04-06 18:22 Axuanup 阅读(221) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> //tpyedef 关键字有什么用,我们每次使用结构体的时候,都要加,struct 这个关键字 //使用tepydef 关键字我们给struct关键字给定义个别名,这样我们定义的时候就不用加struct 这个关键字了 /* 定义方式 typedef struct 阅读全文
posted @ 2020-04-06 18:08 Axuanup 阅读(507) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 3 //结构体关键字struct 4 //定义一个游戏玩家的NPC 5 struct Gamer 6 { 7 char cName[24]; //玩家名称 8 int nHealth; //生命值 9 int nMagic; //魔法 10 int nSk 阅读全文
posted @ 2020-04-06 17:41 Axuanup 阅读(923) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int strlen(char* p);//获取字符串的长度 void strcpy(char* des, char* src); //字符串拷贝 char strcat(char* des, const char* stc); //字符串拼接 //字符串拷贝 v 阅读全文
posted @ 2020-04-06 17:06 Axuanup 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 void loop_a(void); 3 void loop_b(void); 4 void loop_c(void); 5 void loop_d(void); 6 7 8 void loop_a() 9 { 10 int i = 0; 11 while 阅读全文
posted @ 2020-04-03 23:09 Axuanup 阅读(252) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> int main(int argc, char *argv[]) { int x = 2; int y = x; int* p1 = &x; int* p2 = p1; printf("只拷贝值,不拷贝地址\n"); printf("深拷贝:x = %p,val 阅读全文
posted @ 2020-04-03 22:40 Axuanup 阅读(162) 评论(0) 推荐(0) 编辑
摘要: int arr[5] = {1,2,3,4,5}; int *p = arr; for(int i = 0; i < 5;i++) { arr[i] = 表示数组元素0 *(p+i) = 表示指针元素0 *p+i = 表示指针元素0 p[i] = 表示指针元素0 p++ = 表示指针元素0 } 阅读全文
posted @ 2020-04-03 22:37 Axuanup 阅读(705) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h> int main(void) { int arr[] = { 1, 2, 3, 4, 5, 6 }; //arr数组名本身就是一个指针 int *p = arr; //int *p = &arr[0]; //和int *p = arr; 是等价的 for (int 阅读全文
posted @ 2020-04-03 22:36 Axuanup 阅读(313) 评论(0) 推荐(0) 编辑