慢慢记录,不断更新。
控制printf输出指定个数的字符
printf格式字符串中,与宽度控制和精度控制有关的常量都可以换成变量,方法就是使用一个*代替那个常量,然后在后面提供变量给*
void dump_received_string(char *buffer, int length) { printf(".*s", length, buffer); }
参考:
https://www.cnblogs.com/yuaqua/archive/2011/10/21/2219856.html
https://blog.csdn.net/yss28/article/details/53538063
这个在程序中确实非常有用。
原文:https://www.cnblogs.com/ssdq/p/13300517.html