char site[];
This code is not legal. Your compiler should be producing an error such as:
main.cpp:5:10: error: definition of variable with array type needs an explicit size or an initializer
char site[];
^
Because in C++ the built-in arrays have a fixed size that is part of their type. If you want a resizable array you should use std::vector for the general case and std::string for strings.
scanf("%s", site);
If char site[] is working your compiler probably creates an array of size zero, so reading anything into it results in a buffer overflow.
send(sock,"GET / HTTP/1.1\r\nHost: " + site + "\r\nConnection: close\r\n\r\n", strlen("GET / HTTP/1.1\r\nHost: " + site + "\r\nConnection: close\r\n\r\n"),0);
This should result in another error along the lines of:
main.cpp:10:42: error: invalid operands to binary expression ('const char *' and 'char *')
send(sock,"GET / HTTP/1.1\r\nHost: " + site + "\r\nConnection: close\r\n\r\n", strlen("GET / HTTP/1.1\r\nHost: " + site + "\r\nConnection: close\r\n\r\n"),0);
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~
In C++ you cannot simply add arrays together. Again, arrays in C++ are fixed size objects. You can however add std::strings together, or you can add a std::string with a const char * (because std::string defines operator+ between itself and const char *).
std::string site;
site = getURL(); // you'll have to implement this, including both getting the string from the user and validating that the user isn't entering in something tricky that will cause security problems
std::string query = "GET / HTTP/1.1\r\nHost: " + site + "\r\nConnection: close\r\n\r\n";
send(sock, query.c_str(), query.size());
std::stringand using + works fine.strcat.std::stringis much more safe and useful than it is "fancy", though.std::stringis about as unfancy as C++ gets.