[英]adding a value in to the http request from a long to char
我試圖在http請求中添加值,並在路徑中添加一個long時遇到錯誤。
long test1, test2;
unsigned long age;
numdata=inet.httpGET("test.com", 80, '/system/get.php?value1='+test1+'&value2='+test2, msg, 50);
錯誤:從'long int'到'const char *'的無效轉換
而且我嘗試了以下操作並出現錯誤。
const char getRequest = '/system/get.php?value1='+test1+'&value2='+test2;
numdata=inet.httpGET("test.com", 80, getRequest, msg, 50);
並且正在收到以下錯誤
錯誤:從'char'到'const char *'的無效轉換
如果更好地為此使用ostringstream
#include <sstream>
std::ostringstream ss;
ss << "/system/get.php?value1=" << test1 << "&value2=" << test2;
那么您可以使用以下命令從字符串流中獲取std::string
ss.str();
無論選擇什么,在處理char
數組時都應使用"
而不是單引號。在處理單個char
變量時,請僅使用單引號。
您目前在這里做什么
const char getRequest = '/system/get.php?value1='+test1+'&value2='+test2;
在聲明const char
這是一個常量字符。 這與char
數組不同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.