Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm compiling my code, no errors. then I run it and get this.

> ./main.o
Welcome.
Please enter your username.
penlands
your user is not in the users file.


Here's the code.

C++
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>

int main() {

std::vector<std::string> users = {"teagan, penlands"};
std::string loginUser;
char* mySecret = getenv("tPassword");

  std::cout << "Welcome.\n";
  std::cout << "Please enter your username.\n";
  std::cin >> loginUser;

  if(loginUser == users[0] || loginUser == users[1]){
std::cout << "What is the password\n";
  }else{
    std::cout << "your user is not in the users file.\n";
  }
}


Does anybody know why this is happening?

What I have tried:

I have checked the code, can't find anything wrong. IDK why it's not working.
Posted
Comments
jeron1 1-Nov-21 17:12pm    
How about;

std::vector<std::string> users = {"teagan", "penlands"};
Teagan Penland 1-Nov-21 17:15pm    
thank you! that worked.
jeron1 1-Nov-21 17:17pm    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900