模拟实现printf
来源:互联网 发布:光大证券金阳光mac版 编辑:程序博客网 时间:2024/06/04 18:55
#include<stdio.h>#include<stdarg.h>void display(int tmp){ if(tmp > 9){display(tmp / 10);}putchar(tmp % 10 + '0');}void print(const char *format, ...){va_list arg;va_start(arg, format);while ((*format) != '\0'){switch (*format){case 'c':{char tm = va_arg(arg, char);putchar(tm);break;}case 's':{char* tmp = va_arg(arg, char*);while ((*tmp) != '\0'){putchar(*tmp);tmp++;}}break;case 'd':{int tmp = va_arg(arg, int);display(tmp);break;}default:{putchar(*format);}}format++;}}int main(){print("s ccc d.\n", "hello", 'b', 'i', 't',100);getchar();return 0;}
阅读全文
0 0
- 模拟实现 printf 函数
- 模拟实现printf
- 模拟实现printf
- 模拟实现printf函数
- 模拟实现printf
- 模拟实现printf函数
- 简单模拟实现printf函数
- 可变参数模拟实现printf
- printf函数的简单模拟实现
- 模拟实现库函数——printf
- 利用可变参数模拟实现简易printf
- 模拟实现printf函数(可变参数)
- 模拟实现printf函数,完成函数调用
- 用可变参数列表模拟实现printf函数
- 【C/C++】利用可变参数模拟实现printf
- 模拟实现printf函数,可变参数列表实例
- printf实现
- printf实现
- Vjudge攻略——POJ1753
- IntelliJ IDEA 2017激活(Mac版本)
- 利用MFC绘制Excel数据的波形
- 循环:念整数
- 【TED】The psychology of self-motivation--Scott Geller
- 模拟实现printf
- 装饰者模式
- 【Caffe的C++接口使用说明(一)】caffe_windows下的第一个测试程序学习教程
- #300. 【CTSC2017】吉夫特
- caffe学习笔记(八)——binaryproto 转 npy、mat文件
- C语言单向链表的实现
- 【VS插件】Image Watch插件
- 数组:井字棋
- 【脚本语言系列】关于Python网页服务Plone,你需要知道的事