nrf24 send string using radiohead library

I try to put a string in a variable then send the variable to my sever.

When i put in:

uint8_t data[] = "Hello World!";
nrf24.send(data, sizeof(data));

:

The client will send the data and the server will get request: hello world.

When i try to convert an int to a string and put the string variable in i get an error:

int testing = 50;
String myString = String(testing);

uint8_t stringValue[] = testing;
nrf24.send(stringValue, sizeof(stringValue));

:

error =:

nrf24_client:33: error: initializer fails to determine size of 'stringValue'

uint8_t stringValue[] = testing;

^

nrf24_client:33: error: array must be initialized with a brace-enclosed initializer

exit status 1
initializer fails to determine size of 'stringValue'
:

I am fairly new with c++ and spend alot of time figuring out how to make this work with no succes.

nrf24_client:33: error: array must be initialized with a brace-enclosed initializer

This is telling you how to correct the error, but that isn't what you should be doing.

If you want to convert an integer to a character array for transmission, the easiest way is to use the function itoa(). We recommend to avoid using Strings, as they tend to corrupt memory on an Arduino.

Possible example code:

   int testing = 50;
   char stringValue[8]; //make this big enough for the character string plus zero terminator
   itoa(testing, stringValue, 10); //convert integer to ASCII string, number base 10
   nrf24.send(stringValue, strlen(stringValue));  //use strlen() to determine C-string length

Hello,

Maybe it's a bit late, but there is an easy way to send float or string. Heres a snippet for example float:

float battVoltageReading;

String batt = String(battVoltageReading,2);

uint8_t data[batt.length()];

for(int i=0;i<batt.length();i++){
data*=batt.charAt(i);*
}

nrf24.send(data, sizeof(data));
Cheers