int _tmain(int argc, _TCHAR* argv[]) { std::string Server, UserName, Password; int Port=0; //////////// GET SERVER NAME //////////////////// cout << "\n\n\n\nPlease enter Server name or IP: "; getline (cin, Server); if (Server.length()==0) goto exit; bool hasSpace =false; int i=0; while( i < Server.length()) { if(Server[i++] == ' ') hasSpace = true; //whatever } if (hasSpace) { cout << "\nError: Server name cannot contain spaces!\n\n"; goto wait_exit; } //////////// GET PORT NUMBER //////////////////// cout << "\nServer Port number: "; cin >> Port; if (Port==0) goto exit; if (Port <0) { cout << "\nError: Port number cannot be negative!\n\n"; goto wait_exit; } if (Port >99000) { cout << "\nError: Port number cannot out of range! Maximum port number 99000.\n\n"; goto wait_exit; } //////////// GET USER NAME //////////////////// cout << "\n\n\n\nPlease enter User name: "; getline (cin, UserName); //misses this if (UserName.length()==0) goto exit; //does not come to here wait_exit: printf("\n"); system("pause"); exit: return 0;
getline (cin, UserName);
cin >> Port;
>>
getline()
cin.clear(); cin.ignore(1000,'\n');
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)