1
我正在用C++編寫服務器程序,我在接受const char
的方法。我有這個代碼,但它不會編譯說const char變量的問題
27 26 C:\Users\Owner\Desktop\main.cpp [Error] expected primary-expression before ',' token
有人可以請解釋發生在我身上的事情。
std::string str = "Hello";
const char * c = str.c_str();
iResult = getaddrinfo(c*, 23, &hints, &result);
我試過,但後來我的編譯器抱怨,說27 46 C:\ Users \ Owner \ Desktop \ main.cpp [錯誤]從'int'無效轉換爲'const char *'[-fpermissive] – 2013-04-21 12:43:20
@JoshSobel:請參閱我編輯的答案。 – RichieHindle 2013-04-21 12:43:48
哦,謝謝虐待當我無法知道端口號是一個字符串時接受它 – 2013-04-21 12:44:27