I
Inner Dragon
Hey guys, I've been having a real hard time trying to pass a string as
parameter and then converting it to char to be used with
SDLNet_TCP_Recv. It's been hell with me though, here's my non-working
code... any help is greatly appreciated!
------------------------------------------------------------------------------------------------
void Login(std::string &pass){
cout << pass << endl;
char * loginstr;
/*
What I want to archieve is to be able to use:
sprintf(loginstr,"user\npass");
And then send it to the respective function, Send():
void Send(char *msg){
SDLNet_TCP_Send(sock,msg,strlen(msg));
}
as: Send(loginstr);
*/
}
int main(int argc, const char* argv[]) {
std::string pass;
cout << "Password: ";
cin >> pass;
Login(pass);
return(0);
}
----------------------------------------------------------------------------------------
parameter and then converting it to char to be used with
SDLNet_TCP_Recv. It's been hell with me though, here's my non-working
code... any help is greatly appreciated!
------------------------------------------------------------------------------------------------
void Login(std::string &pass){
cout << pass << endl;
char * loginstr;
/*
What I want to archieve is to be able to use:
sprintf(loginstr,"user\npass");
And then send it to the respective function, Send():
void Send(char *msg){
SDLNet_TCP_Send(sock,msg,strlen(msg));
}
as: Send(loginstr);
*/
}
int main(int argc, const char* argv[]) {
std::string pass;
cout << "Password: ";
cin >> pass;
Login(pass);
return(0);
}
----------------------------------------------------------------------------------------