두 개의 정수와 문자열을 버퍼에 복사하고 버퍼 요소를 인쇄하려고합니다. 세 번째 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];
왜 이것이 오류입니까?
이 "F"로 버퍼로 선언 된 것입니다 - 당신이 bufer가 [444] – Hogan
방법 * 문자열 서명 숯불이다라고 *와 * STR * 선언? – karlphillip