memcpy() problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • danu

    memcpy() problem

    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_nu m); /* htonl: used to convert the
    actual packet_num into network numbers*/
    memcpy(buf, &seq_num, 4);
    .....
    .....
    }

Working...