Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Need some help loading up keys into a structure array.
Post Flair (click to view more posts with a particular flair)
Post Body

In my main:

#include <iostream>

include <fstream>

include <string>

using namespace std;

struct Employee { string name; int nKeysPossessed; string keys[5]; };

bool reader(string input_filename, Employee employees[], int& nEmployees) {     /This function should take a string for the filename,     an array of Employee array, and the number of employees (should be passed in as reference) as input./ int keyNum = 0;

string enter;

string names;

string key;

ifstream ifs;

ifs.open(input_filename);

if(!ifs.is_open())     { return false;     }

getline(ifs, enter);

int count = stoi(enter);

nEmployees = count;

for(int i = 0; i < nEmployees; i )     { getline(ifs, names);

ifs >> keyNum;

ifs.ignore();

getline(ifs, key);

string finder = " "; string arr[keyNum]; int end = key.find(finder); int count = 0; int start = 0; string j;

for(int j = 0; j < keyNum; j )         { arr[j] = key.substr(start, end - start); start = end finder.size(); end = key.find(finder, start); cout << arr[j] << endl; cout << key << endl;         } employees[i].keys[0] = "Yes"; cout << employees[i].keys[0] << endl; cout << keyNum << endl;

while(count < keyNum)             { employees[i].keys[count] = arr[count];             }

cout << endl;

employees[i].name = names; employees[i].nKeysPossessed = keyNum;

    }

return true; }

int main() {

cout << "Please enter key file name to start: " << endl;

int nEmployees = 0;

string inputFile; cin >> inputFile;

string number; int size;

ifstream findEmployee; findEmployee.open(inputFile);

getline(findEmployee, number);

size = stoi(number);

Employee employees[nEmployees];

bool readerDetermine = reader(inputFile, employees, nEmployees);

if(readerDetermine == true)     { cout << "it is working so far" << endl;     }

if(readerDetermine == false)     { cout << "Something wrong chief" << endl;     }

return 0;

}

With an input file of this:

2
Ya Hoo
3 AHC102 AHC200 AHC111
Michael Lee
3 AHC303 AHC200 AHC324

I keep on trying to work it out, and every time I try to fill up the structure array, it comes out poorly. I was wondering if anyone could help me out, this is the only thing I need to REALLY get started on this program (I hope).

Author
Account Strength
40%
Account Age
1 year
Verified Email
Yes
Verified Flair
No
Total Karma
21
Link Karma
2
Comment Karma
19
Profile updated: 20 hours ago
Posts updated: 5 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago