gpt4 book ai didi

c++ - 附加套接字字符数组

转载 作者:行者123 更新时间:2023-11-28 01:29:15 29 4
gpt4 key购买 nike

<分区>

字符串变量和字符变量 cout 不止一次,如图所示。我有 ZeroMem() 增益 我如何对其进行标准化,以便它计算出“Invader Said:Reddit”而不是“Invader Said:RedditInvader Reddit”。

char buff[4096];
string serverMessage = "GET OUT MY SERVER!";

while (true) {
ZeroMemory(buff, 4096);

int bytesRecived = recv(clientSocket, buff, 4096, 0);

if (bytesRecived == SOCKET_ERROR) {
cerr << "Error in recv()! Qutting!" << endl;
}

if (bytesRecived == 0) {
cout << "Client Disconnected" << endl;
break;
}

cout << "Invader Said: " << buff;
send(clientSocket, (char*)serverMessage.c_str(), serverMessage.length(), 0);
}

Problem Visualized

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com