I am unclear about what you're trying to do.
Are you trying to send a single char via your socket?
And how is userinput declared?
I want *sendbuf to equal userinput.
userinput is declared somewhere else in the program as "char userinput;"
The following function requires the sendbuf variable to be "const char *":
"send(ConnectSocket, sendbuf, (int) strlen(sendbuf), 0);"
I want to use "cin >> userinput;" and ask the user to input a text string. I then want the contents of userinput to put into char *sendbuf.
If userinput is just a single char, as
char userinput;
suggests, then you can send it like this
1 2 3 4 5 6 7 8 9 10
|
// usual include files assumed...
char userinput;
cout << "input a char: ";
cin >> userinput;
char *sendbuf = &userinput; // take the address of char
send(ConnectSocket, sendbuf, 1, 0); // send single char
|
or you can skip sendbuf variable and pass address of char to send()
1 2 3 4 5 6 7 8
|
// usual include files assumed...
char userinput;
cout << "input a char: ";
cin >> userinput;
send(ConnectSocket, &userinput, 1, 0); // send single char
|
Is this what you want to do??
Andy
Last edited on