zoukankan      html  css  js  c++  java
  • typedef的用法

    为数据类型取别名

     1 #include<stdio.h>
     2 
     3 typedef int i; //为int再重新多取一个名字,i等价于int
     4 
     5 typedef struct student{
     6     int sid;
     7     char sex;
     8 }ST;//为struct student再重新多取一个名字为ST,下面有用到struct student的地方都可以用ST代替
     9 
    10 int main(){
    11     int a=10;//等价于 i a=10;
    12     struct student st;//等价于ST st;
    13     struct student *ps;//等价于ST *ps;
    14     return 0;
    15 }
     1 #include<stdio.h>
     2 
     3 typedef struct student{
     4     int sid;
     5     char sex;
     6     }* PST,STU;//用逗号隔开,PST等价于struct student *,STU代表struct student
     7 
     8 int main(){
     9     STU st;  //struct student st
    10     PST ps = &st;  //struct student * ps = &st;
    11     return 0;
    12 }
  • 相关阅读:
    r语言
    pickle模块
    mongodb简介
    oracle
    mysql
    ceph
    迭代器
    python类
    encode&decode
    PHP 截取字符串中某两个字符(串)之间的字符串 考虑多个的情况
  • 原文地址:https://www.cnblogs.com/sunbr/p/11318582.html
Copyright © 2011-2022 走看看