I am trying to to add value in to the http request and getting errors when I add a long into the path.
long test1, test2;
unsigned long age;
numdata=inet.httpGET("test.com", 80, '/system/get.php?value1='+test1+'&value2='+test2, msg, 50);
error: invalid conversion from 'long int' to 'const char*'
And I have tried the following and getting an error.
const char getRequest = '/system/get.php?value1='+test1+'&value2='+test2;
numdata=inet.httpGET("test.com", 80, getRequest, msg, 50);
And am getting the following error
error: invalid conversion from 'char' to 'const char*'
If would be better to use a ostringstream
for this
#include <sstream>
std::ostringstream ss;
ss << "/system/get.php?value1=" << test1 << "&value2=" << test2;
then you can get at the std::string
from the string stream using
ss.str();
Whatever you choose you should use "
instead of single quotes when dealing with a char
array. Use only single quotes when dealing with a single char
variable.
What you are currently doing here
const char getRequest = '/system/get.php?value1='+test1+'&value2='+test2;
is declaring a const char
- that is a single constant character. This is not the same as an array of char
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.