美文网首页
标准C的一些操作(二)

标准C的一些操作(二)

作者: 菜菜子_forest | 来源:发表于2020-03-07 22:11 被阅读0次

    1、字符串大小写转换

    //字符串全部转为大写

    char *strupr(char *str) {

      char *orign = str;

      for (; *str != '\0'; str++)

        *str = toupper(*str);

      return orign;

    }

    //字符串全部转为小写

    char *strlowr(char *str) {

      char *orign = str;

      for (; *str != '\0'; str++)

        *str = tolower(*str);

      return orign;

    }

    2、查找最后一个被查字符,并返回从该字符开始的字符串

    char* tmpcfileName = "123.123.exe"

    char *rightStr = strrchr(tmpcfileName, '.');

    rightStr 为.exe

    3、获取系统当前时间

    #include <time.h>

    #define BUFLEN 255

    time_t t = time(0);

     char tmpBuf[BUFLEN];

     strftime(tmpBuf, BUFLEN, "%Y-%m-%d %H:%M:%S", localtime(&t));

    相关文章

      网友评论

          本文标题:标准C的一些操作(二)

          本文链接:https://www.haomeiwen.com/subject/ynahdhtx.html