Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 1 month ago.
Why is the function strlen(...) not the same as in C++ ??
The function strlen(const char *) does not yield the same result as in C++. It seems to return the size of the array not the length of the string.
According to: http://www.cplusplus.com/reference/cstring/strlen/?kw=strlen the function definition for strlen is: strlen( const char * str )
My code should work, but it does not and I don't know why the function is behaving like this, any advice?
void pcBuf_OnMessageReceived(unsigned char* cmd, unsigned char* data, int length) { /* Transmitter */ rf.Write(data, (unsigned char) strlen(data)); }
Thanks
1 Answer
10 years, 1 month ago.
My bad, got confused between the sending and receiving functions of the RF transceivers, strlen(...) works as expected. printf("RF %i",(unsigned char) strlen((const char *)data));
Assigned to
10 years, 1 month ago.This means that the question has been accepted and is being worked on.