c博客06-2019-结构体&文件

1.本章学习总结

1.1 学习内容总结

结构类型定义的一般形式
struct 结构名 {
    类型名 结构体成员名1;
    类型名 结构体成员名2;
    类型名 结构体成员名3;
        ...
    类型名 结构体成员名n;
};

赋值

struct student{ 
char name[20]; 
int age; 
char sex; 
int weight; 
void *attr; 
};

结构体数组排序做法

正常的利用冒泡排序可以解决问题,若出现数字排序则如下

void swap(struct typedef &S,struct typedef &T)
{
      struct typedef tmp;
     if(S.scroe>T.score)
    {
        tmp=S;
       S=T;
       T=tmp;
     }
}

关于结构体指针的传递

typedef struct{
  int a;
  int b;
  }date;
 static int intcms(void *para){
     int c = ((date *)para)->a;
     printf("c is %d\n",c);
 }
  
 int main(int argc, char **argv)
 {
     date dates;
     dates.a = 9;
     dates.b = 2;
     intcms(&dates);
}

1.2 本章学习体会

  • 本章配合指针难度确实加大了,也由于临近考试周,代码量有所下降,课程跟不上,等空闲下来会多花时间在代码上的。
  • 代码量,因为有在打2840复习C语言,所以代码量大概在600行。

大作业

虽然很想做,但因为不懂的东西太多,实在写不出来。。。

posted @ 2019-12-15 21:04  控响  阅读(165)  评论(0编辑  收藏  举报