Skip to content

Instantly share code, notes, and snippets.

@cquick97
Created May 7, 2015 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cquick97/51d8ba276cd42359e54f to your computer and use it in GitHub Desktop.
Save cquick97/51d8ba276cd42359e54f to your computer and use it in GitHub Desktop.
C++
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string start;
cout << "\nWelcome to my DOS messaging program."; //Begin opening
cout << "\nYou will be able to send messages to people based on their IPv4 address.";
cout << "\nThis will only work with computers on your local network.";
cout << "\nWould you like to continue?";
cout << "\nYes or No: "; //End opening
cin >> start;
if(start=="No" || start =="no")
{
//goto end; //This jumps to the main ending function at the bottom of the page.
// ***** No need to goto end, just return right here:
return 0;
}
if(start=="yes" || start =="Yes") //If start is set to Yes, continue to IP entry, if No, quit
{
int x = 1; // ***** Random variable set to 1 for the loop...
//ipEntry: //Beggining of IP entry code block
while (x == 1){
string ip; //String for IP Address storage
string confirmIP; //Confirms that it is the correct IP
cout << "\nPlease enter the IPv4 of the computer you want to talk to";
cout << "\nIPv4: ";
cin >> ip; //IP Entry
cout << "\nThe IP you entered is: " << ip << endl;
cout << "\nIs this correct? Yes or No: ";
cin >> confirmIP; //Allows user to confirm they inputted the correct IP Address
if(confirmIP == "Yes" || confirmIP == "yes")
{
x = 0; // x isn't 1 so it wouldn't loop.
cout << "\nConnecting to host. Please wait."; //Begin the connection to the other host.
//This is where the network connection should begin. Most likely on a different .cpp document, I just dont know how to do any of that yet.
}
else if(confirmIP == "No" || confirmIP == "no")
{
x = 1; //Make sure x is still 1, so the loop restarts
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment