Loading

C语言 —— sprintf()函数

sprintf() 函数

  

例如:

#include<stdio.h>

int main()
{
    //注意s一定要先初始化!
    char *s = (char*)malloc(40*sizeof(char));   //或char s[40];
    sprintf(s,"%s%d%c","test",1,'2');
    printf("%s",s);
    
    return 0;
}

 

posted @ 2018-09-06 21:22  拾月凄辰  阅读(276)  评论(0编辑  收藏  举报