-->
Page 1 of 1

Convert incoming char* array into String data type

PostPosted: Tue Feb 02, 2016 3:51 am
by helpme
I am using the SMING framework. I have a tcpServer function which receives data from a TCP port. I would like to convert the incoming char *data into String data type.

Code: Select allbool tcpServerClientReceive(TcpClient& client, char *data, int size)
{
    String rx_data;
    rx_data = String(data);
    Serial.printf("rx_data=%s\r",rx_data);
}


The contents of rx_data is rubbish. How to make rx_data into a proper string?

Re: Convert incoming char* array into String data type

PostPosted: Tue Feb 02, 2016 5:04 am
by jeffrey92
I don't know the specifics of the sming c++ implementation but have you tried just doing

Serial.printf("rx_data=%s\r",data); ?