I have a code below, but i can’t put int to my buffer.
unsigned char buffer[1024];
buffer[0] = 0x44;
u_long fd = htonl(VERSION);
memcpy(buffer+1, &fd, 4);
Can you help me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In
ntohl(buffer[1]);value ofbuffer[1]will be taken (a char) and will be casted intolong.This will cause on a little endian machine to take value at&buffer[1]which is obviously 0 for value less than 224(unsigned) as you have calledntohlearlier which reverses byte order.And if you are really interested to look into the buffer then try