zoukankan      html  css  js  c++  java
  • c学习笔记

    1、 printf("%d",sizeof(unsigned)); //4  = int 长度; 

         char 总是1Byte;  short  <= int <=  long ; short 和long 是int的变体,所有short/long 后面都有个int ,平时简写了 ; float<=double

    const long debt =223,float aa=2.2;//const影响声明行中的所有变量
    符号常量:#define , const
    x = 6 = (y = 4 + 5 ) ; //OK

    2、

    struct{
        int a;
        int b;
        char ar[2];//char 型数组很特别,不足4个也要分占4个字节,此处ar[1],a[2],1[3],a[4] 结果一样,在vc6下是这样,其它没试过
    }ss;

    printf("%d",sizeof(ss)); //12

    3、

    char *p = "anjun"; //求指针所指字符串长度,用strlen,

    printf("%d ",strlen(p));

    4、全局变量默认为0

    外部静态变量,只对所在文件有效,且在定义之后的可见。extern 无法引用

    5、按值传递:基本类型和结构;数组只能引用传递

    6、struct tm* localtime(time_t  *ptr);//转换

          time_t mktime(struct tm* ntime);//转换

          char* asctime(struct  tm *ptr);//显示

         char * ctime(time_t *ptr);//显示

         size_t strftime( char *s , size_t max ,char *fmt ,struct tm* ptr);//格式化时间

        double difftime(time_t later, time_t earlier); //计算时差

       clock_t clock(void);//返回开始执行起到现在的时间,单位为1/100秒

    7. void assert(int  expression); //assert.h中,只启用debug才有用

    void perror(const char *msg);//errno.h

    8、bsearch/qsort

    9、memmove 完美代替memcpy//内存块有重叠一定要用memmove

    10、cl /E program.c > xx.xx//编译器预处理

  • 相关阅读:
    Collection接口
    10linux基础-Centos7系统进程管理
    09linux基础-文档归档和压缩
    05Linux基础-vim编辑器和恢复ext4下误删除的文件
    04linux系统基础-文件的基本管理和XFS文件系统备份恢复
    03Linux基础-linux基本命令操作
    02Linux基础-linux的基础操作
    01Linux基础-环境搭建
    3、函数
    1、Python基础二
  • 原文地址:https://www.cnblogs.com/anjsoft/p/3198620.html
Copyright © 2011-2022 走看看