我是C ++的新手,编译时遇到一些问题: 我的代码看起来与此类似:
....
#define MAXMEM 1000
int main(){
unsigned char response[MAXMEM];
char res;
ctn = 1;
......
......
sad = 2;
dad = 1;
lenr = MAXMEM;
command[0] = 0x20;
command[1] = 0x12;
command[2] = 0x01;
command[3] = 0x00;
command[4] = 0x00;
res = CT_data(ctn, &dad, &sad, 5, command, &lenr, response);
printf("\nResponse Code: " + res);
.....
所以现在我遇到了编译错误:
printf("\nDer Response: " + response);
无法添加指针
我该如何解决此错误?谢谢!
答案 0 :(得分:3)
由于命令为char*
,语法为printf("\nDer Response: %s", response);