Well, as I explained, tx_buffer is a pointer, right?
Then sizeof(tx_buffer) will return 4 and sizeof(*tx_buffer) won't work because void has no size.
Strlen, however, is different. It searches the string you pass for '\0' and returns the length it found. In other words, strlen returns the actual length of your string and sizeof returns the actual size of your buffer.
But remember that sizeof an array returns the total length of the array, but sizeof a pointer returns the size of the pointer or sizeof(*type) gives the size of one element, not the whole buffer/array.
Strlen is not to be used for finding the length of binary data. It is only guaranteed to work for finding the length of C-style strings.



LinkBack URL
About LinkBacks



