Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void initializeFiles()
- {
- int counter = 0;
- ifstream theFile_1;
- //File 1
- theFile_1.open("Employee_Info.txt");
- if (theFile_1.is_open())
- {
- //cout << "File 1 is opened" << endl;
- //While reading from left to right and the document
- //isn't reaching the end of file
- while (!theFile_1.eof())
- {
- theFile_1 >> col1[counter];
- theFile_1 >> col2[counter];
- theFile_1 >> col3[counter];
- theFile_1 >> col4[counter];
- theFile_1 >> col5[counter];
- theFile_1 >> col6[counter];
- theFile_1 >> col7[counter];
- counter++;
- }
- }
- else
- {
- cout << "File 1 isn't opened" << endl;
- }
- cout << "where is counter now: " << counter << endl;
- for (counter; counter < THE_ARRAY_SIZE; counter++)
- {
- col1[counter] = -1;
- col2[counter] = -1;
- col3[counter] = -1;
- col4[counter] = -1;
- col5[counter] = -1;
- col6[counter] = -1;
- col7[counter] = -1;
- }
- //cout << "Debug: col1[0] is " << col1[0] << endl;
- counter = 0;
- theFile_1.close();
- ifstream theFile_2;
- //File 2
- theFile_2.open("Employee_profile.txt");
- if (theFile_2.is_open())
- {
- //cout << "File 2 is opened" << endl;
- //While reading from left to right and the document
- //isn't reaching the end of file
- string temp_STR1 = "", temp_STR2 = "";
- int met_space = 0;
- while (!theFile_2.eof())
- {
- getline(theFile_2, STR1[counter]);
- getline(theFile_2, STR2[counter]);
- getline(theFile_2, STR3[counter]);
- //cout << STR1[counter] << endl;
- //cout << STR2[counter] << endl;
- getline(theFile_2, STR4[counter]);
- temp_STR1 = "";
- temp_STR2 = "";
- met_space = 0;
- for (int u = 0; u < STR4[counter].length(); u++)
- {
- if (STR4[counter][u] == ' ')
- {
- //if encounter a space then set met_space to 1
- met_space = 1;
- }
- else if (met_space == 0)
- {
- temp_STR1 += STR4[counter][u];
- }
- else if (met_space == 1)
- {
- temp_STR2 += STR4[counter][u];
- }
- }
- STR4[counter] = temp_STR1;
- STR5[counter] = temp_STR2;
- //cout << STR3[counter] << endl;
- counter++;
- }
- }
- else
- {
- cout << "File 2 isn't opened" << endl;
- }
- cout << "where is counter now: " << counter << endl;
- for (counter; counter < THE_ARRAY_SIZE; counter++)
- {
- STR1[counter] = "";
- STR2[counter] = "";
- STR3[counter] = "";
- STR4[counter] = "";
- STR5[counter] = "";
- }
- //cout << "Debug: STR1[THE_ARRAY_SIZE-1] length is " << STR1[THE_ARRAY_SIZE - 1].length() << endl;
- theFile_2.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement