特牛网址导航

C语言字符串不定长参数处理_c sscanf 不定长输入-CSDN博客

网友收藏
文章浏览阅读1.1k次。有时候需要写一个不定长参数的传入,怎么办?比如:写一个显示函数 show(char *str);用于在某些特殊屏幕显示。但是这个str 是一个固定的参数,所以要先做 sprintf(str,format,…);然后才能传给它。这样比较麻烦,直接写成 show(char *str,int len,char *format,…);输入不定长参数,更加方便。代码如下:#include <stdlib.h>#include <stdio.h>#include <sys/_c sscanf 不定长输入