Hey all. I'm new to the community and I have found it very useful in the past.
I have a problem that I cannot find a solution to:
Here is the question
As a system administrator, your task is to write a computer program for the CompanyINFR1100 to manage its user’s records. The program should allow its user to:
- Read all the records from the database text file, MasterUserFile.txt.
- Add a new user.
- Remove a user, given his/her user ID.
- Change the priority of a user, given his/her user ID.
- Change the password of a user, given his/her user ID.
- Print all the data for a specific user, given his/her user ID.
- Print all the data for all users in the company.
- Write records to the database text file
Hint: Your program should read the data file, fill an array of structures (one structure for each user), and perform all operations (except the reading and writing operations) on the array of structures.
So i've broken it down.
1st step would be to open the file.. and read all of the information into an array. The array contains alphanumeric entries (passwords, names etc.)
Question 1: How can I get an array to read this kind of data into corresponding entries?
Heres what I have so far.. i'm totally clueless.
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
//Global Variables
int intIndex=5;
int intIndexSize=5;
struct UserFields
{
//Structure Fields
char firstName [10];
char lastName [10];
char password[10];
int priority[1];
int user_id [10];
};
int main()
{
// Declaration of the Array of Structs with size intIndex
UserFields Users[intIndex];
// Install the inStream
ifstream inStream;
// CHECK TO SEE IF FILE WILL OPEN \\
inStream.open("MasterUserFile.txt");
if ( inStream.fail())
{
cout << "Cannot open MasterUserFile.txt for reading, aborting" << endl;
exit(1);
}
}
return 0;
}