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));
网友评论