What I figure is that it's essentially a pointer to the byte after the structure. So if you were making an IP header for example you would define the IP stuff in the structure and have a placeholder for the following TCP header...
thanks for the link.
currently i am a little dizzy,could not understand what the link trying to convey ? I might read them again in the next morning or some other time.
Typically it is a C way of saying that an arbitrary number of bytes follow.
A contrived example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct packet {
int from;
int to;
int data_len;
char data[0]; // length of data is known at runtime, not compile time
};
void send_data( char buf[], int len, int from, int to ) {
struct packet* pkt = (struct packet*)malloc( sizeof( struct packet ) + len ); // allocate space for packet AND data
pkt->from = from;
pkt->to = to;
pkt->data_len = len;
memcpy( pkt->data, buf, len );
// ...
}
However, to be portable, you should not use zero-length arrays.