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.

Ex:

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)

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

char recvbuffer[512];
MessageBox(hWnd, recvbuffer, "Character to String");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.