소스 검색

universal place holder, segmentation error remains,

- Place holders are now universalized with password & password2
- Unneeded variables removed (counter, x, pswd)
- Fixed quit() improper ofstream behavior
- Implemented while (!.empty()) instead of for loop
Fixing-travis-yml
BinHong Lee 8 년 전
부모
커밋
a419dbed0a
3개의 변경된 파일26개의 추가작업 그리고 23개의 파일을 삭제
  1. +23
    -21
      LogInSystem.cpp
  2. +1
    -1
      Person.cpp
  3. +2
    -1
      database.txt

+ 23
- 21
LogInSystem.cpp 파일 보기

@@ -1,6 +1,6 @@
/*
* Written by : BinHong Lee
* Last edited : 4/12/2016
* Last edited : 5/12/2016
*/

#include <iostream>
@@ -10,8 +10,10 @@
#include "Person.cpp"
using namespace std;

int getUsernameCounter(string, int);
//Declaration of functions
void getUser(string);
void login();
void adminLogin();
void loggedIn();
void registration();
void editCredentials();
@@ -22,14 +24,16 @@ void chgEmail();
void chgPhoneNo();
void quit();

//Stacks to store the data
stack<Person> users;

//Declaration of place holding variables
Person currentUser;
string username;
string password;
string password2;
string email;
string phoneNo;
int counter;
int x = 0;
int wrongPass = 0;

int main()
@@ -99,7 +103,6 @@ void login()
}

try {
string usrnme, pswd;
cout << "Username:";
cin >> username;

@@ -126,8 +129,6 @@ void login()

void registration()
{
string pswd = "2";
string pswd2 = "3";
bool available = true;

do
@@ -157,16 +158,14 @@ void registration()
do
{
cout << "Password : ";
cin >> pswd;
cin >> password;

cout << "Confirm password :";
cin >> pswd2;
cin >> password2;

if (pswd != pswd2)
if (password != password2)
cout << "Password unmatched. Please try again.";
} while (pswd != pswd2);

password = pswd;
} while (password != password2);

cout << "Email : ";
cin >> email;
@@ -247,6 +246,7 @@ void update(Person newUser)
{
if (users.top().getName() == currentUser.getName())
{
cout << "replaced" << endl;
newUsers.push(newUser);
}
else
@@ -258,26 +258,29 @@ void update(Person newUser)
}

users = newUsers;
currentUser = newUser;
}

void chgUsername()
{
bool available = true;

bool available;
Person newUsers;

do
{
available = true;
cout << available << endl;
cout << "Username : ";
cin >> username;

stack<Person> temp = users;

for (int i = 0; i < x; i++)
while (!temp.empty())
{
if (temp.top().getName() == username)
{
cout << "Username unavailable. Please try again." << endl;
cout << temp.top().getName() << " " << temp.top().getPhoneNo() << endl;
available = false;
break;
}
@@ -300,15 +303,13 @@ void chgPassword()

while (!currentUser.checkPassword(password))
{
cout << "Wrong password. Please try again.";
cout << "Wrong password. Please try again." << endl;
wrongPass++;

cout << "Please input the current password : ";
cin >> password;
}

string password2;

do {
cout << "Please input the new password : ";
cin >> password;
@@ -343,9 +344,10 @@ void quit()
{
ofstream fout("database.txt");

for (int i = 0; i <= x; i++)
while (!users.empty())
{
fout << username[i] << " " << password[i] << " " << email[i] << " " << phoneNo[i] << " " << endl;
fout << users.top().getName() << " " << users.top().getPassword() << " " << users.top().getEmail() << " " << users.top().getPhoneNo() << " " << endl;
users.pop();
}

exit (EXIT_SUCCESS);


+ 1
- 1
Person.cpp 파일 보기

@@ -1,6 +1,6 @@
/*
* Written by : BinHong Lee
* Last edited : 4/22/2016
* Last edited : 5/11/2016
*/

#include <string>


+ 2
- 1
database.txt 파일 보기

@@ -1,3 +1,4 @@
binhonglee bhlee03655 binhonglee@hotmail.com +13479618886
binhong binhong binhong@binhong.me +14802527013
who what why@binhong.me +where
who whut wtf_is_happening@binhong.me +999999999
testing password testing@binhong.me +601111111111

불러오는 중...
취소
저장