troubleshooting Question

Options

Avatar of Sargie93
Sargie93 asked on
C++
10 Comments1 Solution258 ViewsLast Modified:
Hey, sorry if you've already seen/helped me with this, but I have additions I want to make to the program. The program kind of works like a log in system, you enter one of two names and a welcome screen is output, anything else and it's access denied. What I want to do now is make it so that each name has a different welcome screen.

This is the code I've already got which includes what I've added in an attempt to make this possible, although what I've done has had virtually 0 effect.

Thank you. :)

#include <Windows.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
#include <conio.h>

using namespace std;

struct first

{
      string user;

};

struct second

{
	string user;

};

void WelcomeUser(const struct first& A)
{
  string fname;
  size_t pos = A.user.find(' '); // locate blank

  if (string::npos == pos) // no blank?
  {
    cout << "Welcome " << A.user; // OK, full name
  }

  fname = A.user.substr(0,pos); // extract first name

cout << "Welcome " << fname;
}

void WelcomeUser(const struct second& B)
{
  string fname;
  size_t pos = B.user.find(' '); // locate blank

  if (string::npos == pos) // no blank?
  {
    cout << "Hello " << B.user; // OK, full name
  }

  fname = B.user.substr(0,pos); // extract first name

cout << "Hello " << fname;
}

 int main()

 {
      system("color 0F");

      struct first A;
	  struct second B;

	  cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
	  cout << "                               Press Enter";
	  cin.ignore();
	  system("CLS");

      cout << "Initiating Program..." << endl;
      Sleep (1000);
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "" << endl;
      cout << "NOW LOADING...:  ";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      Sleep (500);
      cout << "|";
      system("CLS");
      cout << "Please Verify Your Name..." << endl;
	  getline(cin, A.user); 
	  getline(cin, B.user);

      
bool correctName=false;
while(!correctName)
{

      //Set A.user here...

      if (A.user == "Josh Sarge" || B.user == "Mike Sarge")
      {
            correctName=true;

            cout << "" << endl;
            cout << "Program Now Processing...Please Wait..." << endl;
            Sleep (2000);
            Sleep (1000);
            cout << "Verification Complete..." << endl;
            Sleep (2000);
            Sleep (1000);
            system ("CLS");
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
            cout << "Access Granted..." << endl;
            Sleep (2000);
            Sleep (1000);
            system("CLS");
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
            WelcomeUser(A);
			cout << "" << endl;
            Sleep (2000);
            Sleep (1000);
            system("pause");
            return 0;

      }
        else
        {
        cout << "" << endl;
            cout << "Program Processing. Please Wait..." << endl;
            Sleep (2000);
            Sleep (1000);
            system("CLS");
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
            cout << "Access Denied..." << endl;
            Sleep (2000);
            Sleep (1000);
            cout << "" << endl;
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
            cout << "Please Enter Your Full Name" << endl;
            cout << "" << endl;
            getline(cin, A.user); 
			getline(cin ,B.user);
      }

}

}
                                            
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros