0
我在Arduino的这段代码strcat的不冲水
void function(int x){
char* response="GET /postTEST.php?first=";
char strx[2] = {0};
int num = x;
sprintf(strx, "%d", num);
original=response;
strcat(response,strx);
Serial.println(response);
//memset(response,'\0',80);
}
基本上,这是加入到我的帖子字符串的整数。不幸的是,它不知怎么成长,并且变成了 GET /postTEST.php?first=0 GET /postTEST.php?first=01 GET /postTEST.php?first=012 随着我增加i。
怎么回事?
是传递的整数一个数字?这就是你用'strx [2]'分配空间的全部内容。 – 2013-02-24 12:30:42