I'm currently doing a program in c++ related to windows socket. On the part where I'm going to receive the answer from an http request and put the data inside of a buffer, I declared the size of the buffer which is 10000, my question is how can I allocate memory during runtime and will no need to declare the size of the buffer during compiling?
Initial code for receiving the data from http request:
char buffer[10000];
// Receiving and Displaying an answer from the Web Server
ZeroMemory(buffer, sizeof(buffer));
while ((dataLen = recv(Socket, buffer, sizeof(buffer), 0) > 0))
{
int i = 0;
while (buffer[i] >= 32 || buffer[i] == '\n' || buffer[i] == '\r') {
cout << buffer[i];
i += 1;
}
}
thanks for the help!