Hello everyone.

I have managed to connect a winsock client to a server application; however, I do not know how to display the results that are recieved inside of my "recv" buffer as a unified string, as apposed to the char array format it is currently in.

I would like to display a whole text string inside of a MessageBox, however, because the recv buffer is in char format, I do not know how to go about displaying what is inside of the buffer as a string.


char recvbuffer[512];
MessageBox(hWnd, (const char*) recvbuffer[0], "Character to String");

As you can see in the code above,
I am only able to display one character at a time from
the character array. What I would like to do is combine all of the characters inside of the array, into a "line" of text, and display that as the message that appears inside of the message box.

Does anyone know how I would be able to convert the characters that are in a char array, into a single unified message that I would be able to display in a MessageBox? (In const char* format)

Edited by PixelExchange: n/a

6 Years
Discussion Span
Last Post by PixelExchange

Yeah, easy. A string is a list of chars. All you have to do is:

char recvbuffer[512];
MessageBox(hWnd, recvbuffer, "Character to String");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.