I a menu that displays first thing when running my winsock application, I'd like to be able to choose a port on startup but I am having problems converting int to PCSTR or any other type of conversion as I have tried a few.
Here is some code:
My header file:
char* DEFAULT_PORT = "10187";
My cpp file:
cout << "\n Input port: ";
cin >> UserDefinedPort;
if (UserDefinedPort > 1000){
char* p = p + UserDefinedPort;
DEFAULT_PORT = p;
} else {
// err...
}
Beginning of my sock function:
int SocketAddrInfo(int iResult, addrinfo* MySocket, addrinfo** MySocketResult){
iResult = getaddrinfo(NULL, DEFAULT_PORT, MySocket, MySocketResult);
if (iResult != 0) {
printf("Get address info failed with error: %d\n", iResult);
WSACleanup();
std::cout << "Server closing in 5 ";
for (int i = 4; i > 0; i--){
Sleep(1 * 1000);
cout << i << " ";
}
cout << "Server closing now!" << endl;
return 1;
}
return iResult;
}
It throws read mem errors or some type of kernel.dll error no matter what method I try.
Any help would be great, thanks in advance!