C 语言 如何在char*中插入一个变量?

定义char* other;
另有int key是会变化的
要是数组输出 “这是关键字(key的值)包含的信息"。应该怎么写?

第1个回答  2012-05-15
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int main()
{
char * other;
int key;
other = (char *)malloc(30*sizeof(char));
key = 1;
sprintf(other,"这是关键字key的值%d",key);
printf("%s",other);
}本回答被提问者采纳