Content originally posted in LPCWare by TheFallGuy on Tue Oct 07 23:46:12 MST 2014
sizeof() can't 'go wrong'. It is defined as a constant, being the size, in bytes, of the variable/type. It is calculated at COMPILE TIME.
Without seeing the definition TCP_RX_BUFTEMP, we cannot know for certain, but my guess is that it is defined as a char *, meaning it is a pointer to a character and, being a pointer, has a fixed size of 4. Again, I don't know what your buffer contains, but if it is a C character array (string), you probably want to use strlen(Buffer) - obviously re-ordering the code... If it is NOT a character array, you need to calculate the size in a different way.