ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/*
Filename: tw.cpp
Progname: Telnet Wargames
By: MarkSpr4wl
Date: December 16, 2003
Purpose: Links to good telnet wargames
and telnet shell accounts
that might be of interest to
the novice and expert computer
buff alike.
*/
#include <iostream> // for i/o: cout, cin, endl,cin.get(), etc.
#include <cstdlib> // system() function for telnet site calls
using std::cin; // using cin for input
using std::cout; // using cout for output
using std::endl; // using endl to endlines of output
void call(char option); // calls() function prototype
const char* errorMsg = "invalid"; // invalid input error message
int main(int argc, char** argv)
{
char option;
cout<< endl << endl << endl // visual interface
<< "\t- Telnet - Servers -" << endl << '\a'
<< "\t--------------------" << endl << endl
<< "\t1. Freeshell" << endl
<< "\tQ..Quit" << endl;
do
{
cout<< "\a\n\tEnter choice_ "; // option input and decision call() function
cin>> option;
call(option);
}
while (option != 0); // Checking for q or Q is redundant, it has quit allready.
//What is this zero check anyway?
/* Not needed
if (option != '1' || option != 0) // if unwanted char, errorMsg (same thing here).
{
cout<< '\t' << errorMsg << '\a' << endl;
cout<< "\tEnter choice_ ";
cin>> option;
}
// Hmm.. this sounds like you don't want to exit in the call function afterall?
cin.get(); // pause screen before exit
*/
return 0;
}
void call(char option) // decision switch/case function (system calls for telnet)
{
switch (option) {
case '1' :
system("telnet freeshell.org");
break;
case 'q' :
case 'Q' :
exit(0); // A proper way to exit. system("exit") spawns a new session that runs "exit",
// meaning that it quits immediatedly.
default: // This Might be a better place for bad input
cout<< '\t' << errorMsg << '\a' << endl;
}
}
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.