c语言中sprintf的语法

通常是用来按照一定的格式,给字符窜赋值的,
像char buf[100] = {0};
char s1[10] = "hello world";
char s2[10] = "tom";
sprintf(buf,"zifuchuan is %s,he int %s",,s1,s2);
printf("buf = [%s]",buf);//输出是,也就是buf变成"zifuchuan is helloworld ,he int tom"
同样适合一些 int 类型,
int int1= 10
像sprintf(buf,"%s,%s,%d",s1,s2,int1);
这样得出的字符串是"hellowolrd Tom 10"
posted @ 2015-07-16 10:39  tsguosj  阅读(356)  评论(0编辑  收藏  举报