From 58efe7fdd3928b96ee1cc1d332bc95056fcbeee9 Mon Sep 17 00:00:00 2001 From: Sam Mario Svensson Date: Tue, 19 Nov 2013 14:59:00 +0100 Subject: [PATCH] getline fix in chat program --- Code/Network/OysterNetworkClient/ClientMain.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp index 0c89410b..7f3687dc 100644 --- a/Code/Network/OysterNetworkClient/ClientMain.cpp +++ b/Code/Network/OysterNetworkClient/ClientMain.cpp @@ -59,10 +59,15 @@ void chat(Client client) { client.Recv(msgRecv); - cout<< "Server: " << msgRecv << endl; + cout<< "Client 2: " << msgRecv << endl; cin.getline(msgSend , 255 , '\n'); + if(strlen(msgSend) < 1) + { + strcpy_s(msgSend , " "); + } + if(msgSend != "exit") { client.Send(msgSend); @@ -73,6 +78,8 @@ void chat(Client client) chatDone = true; } + cin.clear(); + } } \ No newline at end of file