How to convert int to char * (string) to C ++?

advertisements

SOCKET lhSocket; int iResult; lhSocket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); char *sendbuf = "this is a test"; iResult = send(lhSocket, sendbuf, (int)strlen(sendbuf), 0 );

printf("Bytes Sent: %ld\n", iResult);

I have client and Server program using sockets in C++ now i send a buffer it is received by server now when server acknowledge me back saying i got your packet i should get that in string format not bytes received : something. how to achieve that ?

My iresult returns me an integer value, I am sending a message over socket to server , i dont want to print it as Bytes sent : 14. I want to print the message sent as string to server. I am dealing with Sockets. How i can achieve this in C++


sendbuf is the string which you are sending. Print sendbuf instead:

printf("Bytes Sent: %s\n", sendbuf);