我试图将两个整数和一个字符串复制到一个缓冲区并打印出缓冲区元素。我得到第三个printf语句的seg故障:将字符串复制到未签名的缓冲区中:分段错误
id = 102;
len = 3;
str = "working";
memmove(buffer,&message_id,sizeof(id));
memmove(buffer+(sizeof(id)),&len,sizeof(len));
memmove(buffer+(2*sizeof(id)),&string, sizeof(str));
printf("1 is: %d\n", buffer[0]);
printf("2 is: %d\n", buffer[4]);
printf("3 is %s\n, buffer[8])); // here is where i get the seg fault should
be a string
/***/
bufer is declared as unsinged char buffer[444];
我不知道为什么这会seg故障?
什么是有两个“F”缓冲声明 - 你说的是BUFER无符号的字符[444] – Hogan 2011-04-28 00:21:09
如何为*串*和*海峡*宣告? – karlphillip 2011-04-28 00:23:43