C语言 sprintf 函数详情

  /******************************************************************************************/

  //@Author:猿说编程

  //@Blog(个人博客地址): www.codersrc.com

  //@File:C语言教程 - C语言 sprintf 函数

  //@Time:2021/07/28 08:00

  //@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!

  /******************************************************************************************/

  #include

  int main()

  {

  char buf[1024] = { 0 };

  sprintf(buf,"www.codersrc.com

  ");

  printf("%s", buf);

  sprintf(buf,"www.codersrc.com age:%d

  ",17);

  printf("%s", buf);

  sprintf(buf,"www.codersrc.com age:%d name:%s

  ",17, "zhangsan");

  printf("%s", buf);

  sprintf(buf,"www.codersrc.com age:%d name:%s height:%f

  ",17, "zhangsan",1.75);

  printf("%s", buf);

  }