9 years, 6 months 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

9 years, 6 months 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));

Accepted Answer

Assigned to Rehan van der Merwe 9 years, 6 months ago.

This means that the question has been accepted and is being worked on.