Connecting Tech Pros Worldwide Help | Site Map

memcpy() problem

danu
Guest
 
Posts: n/a
#1: Oct 23 '06
Basically I'm trying to do here is put the uint32_t seq_num into the
first 4 bytes of the buf. But every time I do this, it wouldn't get
copied in to the buf at all. Can anyone point out the problem. Thanks a
lot.

char buf[packet_size];
uint32_t seq_num = 0;
uint32_t packet_num = 0;

while((nread = read(fd, buf+8, packet_size-8)) 0) {
packet_num++;
seq_num = htonl(packet_num); /* htonl: used to convert the
actual packet_num into network numbers*/
memcpy(buf, &seq_num, 4);
.....
.....
}

Closed Thread


Similar C / C++ bytes