【发布时间】:2015-05-15 17:49:26
【问题描述】:
代码在这里
#include <SFML/Network.hpp>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
char mode = *argv[1];
if(mode == (char) "-s") {
sf::Packet recMessage;
sf::TcpListener tcpListener;
sf::TcpSocket inClient;
tcpListener.accept(inClient);
inClient.receive(recMessage);
cout << recMessage << endl;
}
}
当使用 -s 运行时,我希望程序在收到数据之前不会关闭,但是当我运行程序时它会关闭。
【问题讨论】:
-
提示:
mode == (char) "-s"不正确,不会按照您的预期进行。使用std::strtmp比较字符串。或者,你知道,使用std::string。
标签: c++ network-programming sfml