20210907

 1 #include <stdio.h>
 2 
 3 //int main(int argc, char **argv)
 4 int main(int argc, char *argv[])
 5 {
 6     for(int i = 0; i < argc; i++){
 7         printf("%dth O: %s\n", i+1, *(argv + i));
 8     }
 9 
10     int iArry[] = {1, 4, 5, 8, 3, 2};
11     int size = sizeof(iArry)/sizeof(int);
12     for(int i = 0; i < size; i++){
13         //printf("%d\t", iArry[i]);    
14         printf("%d\t", i[iArry]);    
15     }
16     printf("\n");
17 
18     int *ptrArry = iArry;
19     for(int i = 0; i < size; i++){
20         //printf("%d\t", *(ptrArry + i));    
21         printf("%d\t", *(i + ptrArry));    
22     }
23     printf("\n");
24 
25     return 10;
26 }
 1 #include <stdio.h>
 2 #include <stdbool.h>
 3 #include <string.h>
 4 #include <stdlib.h>
 5 
 6 //#define DataType int
 7 //
 8 #define Size 10
 9 
10 typedef int DataType;
11 
12 /*struct _stu{
13     int id;
14     bool sex;
15     char name[Size];
16 };*/
17 
18 typedef struct _stu{
19     int id;
20     bool sex;
21     char name[Size];
22 } Student;
23 
24 //void outStu(struct _stu stu){
25 void outStu(Student stu){
26     printf("%s info: id-%d sex-%d", stu.name, stu.id, stu.sex);
27 }
28 
29 int main(int argc, char **argv)
30 {
31     //struct _stu stu1;
32     /*Student stu1;
33     stu1.id = 100;
34     stu1.sex = 0;
35     strcpy(stu1.name, "zhangsan");*/
36 
37     Student *ptrStu = (Student *)malloc(sizeof(Student));
38     /*(*ptrStu).id = 100;
39     (*ptrStu).sex = 0;
40     strcpy((*ptrStu).name, "zhangsan");*/
41     ptrStu->id = 100;
42     ptrStu->sex = 0;
43     strcpy(ptrStu->name, "zhangsan");
44     DataType var1 = 3;
45     printf("%d\n", var1);
46 
47     outStu(*ptrStu);
48 
49     return 0;
50 }

代码简单,请同学们自行练习

posted @ 2021-09-07 09:46  叕叒双又  阅读(72)  评论(0编辑  收藏  举报