-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckData.cpp
62 lines (52 loc) · 1.4 KB
/
checkData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include "checkData.h"
void checkData::checkUserInputData(int key)
{
system("cls");
std::ifstream outputFile;
outputFile.open("studentDatabase.txt", std::fstream::out | std::ios::app);
if (outputFile.is_open())
{
std::string studentName;
int studentId;
while (std::getline(outputFile, studentName, '|') && !outputFile.eof())
{
outputFile >> studentId;
if (key == studentId)
{
std::cout << "Your Student ID is verified. Welcome back " << studentName << "." << std::endl;
std::ofstream inputAttend;
inputAttend.open("./attendance.txt", std::fstream::in | std::ios::app);
if (inputAttend.is_open())
{
inputAttend << studentName << " - PRESENT" << std::endl;
}
}
}
}
outputFile.close();
system("pause");
}
void checkData::viewDatavbase()
{
system("cls");
std::cout << "ID Number\tStudent Name";
std::ifstream outputFile;
outputFile.open("./studentDatabase.txt", std::fstream::out | std::ios::app);
if (outputFile.is_open())
{
std::string studentName;
int studentId;
while (std::getline(outputFile, studentName, '|') && !outputFile.eof())
{
outputFile >> studentId;
std::cout << "\n" << studentId << "\t\t" << studentName << std::endl;
}
}
outputFile.close();
system("pause");
}