代码如下:

[mapan@localhost unixNetwork]$ cat test.cpp 
#include<stdio.h>
#include<string.h>


void func(char test1[],char test2[],char test3[])
{
char test[100];
sprintf(test,
"{\r\n meida_code:\"%s\",\
\r\n app_id:\"%s\",\
\r\n user_id:\"%s\",\
\r\n}"
,test1,test2,test3);

printf("%s\n",test);
}

int main()
{
char str1[]="1";
char str2[]="2";
char str3[]="3";

func(str1,str2,str3);

return 0;
}
[mapan@localhost unixNetwork]$ g++ test.cpp
[mapan@localhost unixNetwork]$ ./a.out
{
meida_code:"1",
app_id:"2",
user_id:"3",
}
[mapan@localhost unixNetwork]$

注意 \ 的使用,它起到换行的作用,还有 " 需要进行转义。