[C]日志函数
2015-10-08 08:12
183 查看
//vsprintf_test.c #include<stdio.h> #include<stdarg.h> void Log(char *buf, const char *format,...) { va_list args; va_start(args,format); vsprintf(buf,format,args); va_end(args); printf("%s",buf); } int main(const int argc,const char* argv[]) { char buf[128]; Log(buf,"int test %d\n",123); Log(buf,"char test %c\n",'X'); Log(buf,"string test %s\n","abcd123"); Log(buf,"double test %lf\n",123.456); Log(buf,"float test %f\n","123.456"); Log(buf,"Hex test %02X %02X\n",0x0F,0xFF); Log(buf,"double test with limited fractional part %0.3f\n",123.456789); return 0; }
相关文章推荐
- 商务部预计下半年药品流通业将进入微利化新常态
- [新手技巧] 如何在Ubuntu中添加和删除书签
- ElasticSearch集群部署
- 程序中的除法取余
- 大数据学习篇:hadoop深入浅出系列之HDFS(八) ——RPC通信
- LT8619B,HDMI转RGB,HDMI转LVDS,MHL转RGB,MHL转LVDS
- 懒加载图片
- 模板引擎
- 新手学python--字典
- 视频播放研究
- angular-2
- angular
- 程序流程
- LeetCode (42): Trapping Rain Water
- 《探索需求--设计前的质量》阅读笔记一
- hdu 3460 Ancient Printer trie字典树
- 重载
- CF#306-C - Divisibility by Eight-数学+暴力
- Convolutional Restricted Boltzmann Machines
- 类