strcpy problem, I included cstring, string, iostream, stdio etc but still my compiler says its no a member o std!!

so I have been trying to send the correct kind of char array down a sfml socket, but nothing ever gets sent barring of course text in
""


1
2
char stringtochar[sizeof(output)];
std::strcopy(stringtochar,output);


error: 'strcopy' is not a member of 'std'

one would think I could just pop a string in Brackets here:
ircsocket.send((somestring),sizeof(somestring));

is there an easy way to do this its such a stupid thing to get stuck on, i have found plenty of people having trouble with it but they all forgot the right includes, what could be the issue??
Last edited on
It's strcpy, not strcopy.

Also sizeof() does not get you the length of the string, but the size of the variable. If 'output' is a pointer, then sizeof() will not give you want you want and will result in an undersized buffer. use strlen() instead.

(and don't forget the +1 for the null terminator)
Last edited on
still got this error

cannot convert std::string {aka std::basic_string<char>}' to 'const char*' for argument '2' to 'char* strcpy(char*, const char*)'|

oh thanks for the plus 1, that would have been annoying
Last edited on
oh got it c_str() at the ends :/
If you are trying to copy a std::string to a char array just so that you can pass a const char* to send, you can get a const char* from std::string directly using c_str().
ircsocket.send(somestring.c_str(), somestring.size() + 1);
Last edited on
that wasn't sending for some reason peter, rather fascinatingly...using char something[strl(somestring)+1] was causeing my program to exit emidiatley!!!
Topic archived. No new replies allowed.