const char变量的问题 我在C++中编写一个服务器程序,我接受一个方法: const char < />代码。我有这个代码,但它不会编译 27 26 C:\Users\Owner\Desktop\main.cpp [Error] expected primary-expression before ',' token

const char变量的问题 我在C++中编写一个服务器程序,我接受一个方法: const char < />代码。我有这个代码,但它不会编译 27 26 C:\Users\Owner\Desktop\main.cpp [Error] expected primary-expression before ',' token,c++,winapi,C++,Winapi,有人能解释一下发生在我身上的事吗 std::string str = "Hello"; const char * c = str.c_str(); iResult = getaddrinfo(c*, 23, &hints, &result); 在getaddrinfo(c*,…中有一个额外的*,您应该删除它,第二个参数应该是端口号作为字符串: getaddrinfo(c, "23", &hints, &result); 我试过了,但是我的编译器抱怨说27 46

有人能解释一下发生在我身上的事吗

std::string str = "Hello";
const char * c = str.c_str();
iResult = getaddrinfo(c*, 23, &hints, &result);

getaddrinfo(c*,…
中有一个额外的
*
,您应该删除它,第二个参数应该是端口号作为字符串:

getaddrinfo(c, "23", &hints, &result);

我试过了,但是我的编译器抱怨说27 46 C:\Users\Owner\Desktop\main.cpp[Error]从'int'到'const char*'[-fppermissive]的转换无效。谢谢,当我不知道端口号是字符串时,我会接受它