this doesnt works for me:
char buff[11];
char* msg_ptr;
msg_ptr = buff;
uint8_t id;
uint32_t msg_length;
char msg[] = "hallo";
id = 77;
msg_length = 5;
memcpy(buff, &id, sizeof(uint8_t));
memcpy(buff+1, &msg_length, sizeof(uint32_t));
strcpy(buff+5, msg);
printf("id :%d\n",*(uint8_t*)msg_ptr);
msg_ptr++;
printf("msg_length: %d\n", *msg_ptr);
msg_ptr++;
printf("msg: %s\n", msg_ptr);
Id and msg_lentgh are shown on konsole, but after that i get a segmentation fault. I am new to C please be as detailied as possible. Regards