int main(int argc, char **argv) { string serverConf = "server.properties"; int ch; opterr = 0; while ((ch = getopt(argc, argv, "f:")) != -1) { switch (ch) { case 'f': serverConf = optarg; break; default: printf("other option :%c\n", ch); } } MyServer server; if (0 != server.Run(serverConf)) { printf("Server::Run failed, %s\n", server.GetLastErr()); return -1; } return 0; }