
C/C++
galaxyzwj
Code the Future, change the world
展开
-
C++: string类型的使用
标准库类型string表示可变长的字符序列,使用string类型必须包含string头文件以及命名空间std,即具体如下: #include <string> using namespace std; 1.定义并初始化string对象 如果定义变量时没有指定初始值,则变量在编译时被默认赋予初值(函数内局部变量除外),具体如下: 全局变量、static静态局部变量、无须显示初始化的类 =====> 支持默认初始化 函数内部的局部变量 =====> 必须手动初始化,否则有出现原创 2020-05-24 16:03:40 · 769 阅读 · 0 评论 -
C/C++常用接口:计时操作的函数 get_ms()
接口定义: #include <sys/time.h> unsigned long long get_ms() { struct timeval time_v = { 0 }; gettimeofday(&time_v, NULL); return (unsigned long long)time_v.tv_sec * 1000 + time_...原创 2018-12-23 22:55:13 · 1692 阅读 · 0 评论 -
C/C++常用接口: 调节打印日志级别的接口
接口定义: #define INFOLEVEL 1 #define DEBUGLEVEL 2 #define WARNINGLEVEL 3 #define ERRORLEVEL 4 #define SDK_PRINT(level,fmt,...)\ do {\ if (level > DEBUGLEVEL) {\ printf("%s:...原创 2018-12-23 23:01:04 · 1225 阅读 · 0 评论 -
C/C++常用接口: 添加写入日志到文件的功能
#include <stdio.h> #include <stdarg.h> #include <time.h> int write_log (FILE* pFile, const char *format, ...) { va_list arg; int done; va_start (arg, format); time_t time_lo...原创 2019-04-10 00:33:35 · 1526 阅读 · 0 评论