I have seen many similar questions but none that seem to be working for my code, I think I am overlooking something basic, maybe you can help.
Right now I'm constructing a string to be sent as a request to the winsock send function, which requires a char [] to be sent. I need to convert my std::string into a char array (char []).
Currently this is the request that works:
char request [] = "GET /gwc/cgi-bin/fc?client=udayton0.1&hostfile=1HTTP/1.0\nHost:www.gofoxy.net\n\n";
But I need to change a string of a request to the same data structure.
I appreciate any help!
edit:
I can convert a string to a char *, but how can I use that to get a character array? I hope I'm not making it more confusing. Here are two attempts that produce char star's that aren't compatible with the send request when I run:
//convert request into a char[]
//char *req_ch = new char[req_str.size()+1];
//hostCh[req_str.size()] = 0;
//memcpy(req_ch, req_str.c_str(), req_str.size());
//char * req = new char[req_str.size() +1];
//std::copy(req_str.begin(), req_str.end(), req);
//req[req_str.size()] = '\0';
c_str()what you are looking for, which returns a pointer?vector::data().