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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
void editDetainee()
{
const int size = 10000;
//Detain* detaineeArr = new Detain[size];
int entry_count = 0;
string code_input, det_code, new_det_code, n_e ;
ifstream infileD("detainees.txt", ios::in);
char line[220];
while (infileD)
{
infileD >> line;
if (strcmp(line, "--------------------") == 0)
{
entry_count++;
}
}
cout << "size = " << entry_count;
cout << endl;
cout << " Enter the code of detainee: ";
cin >> det_code;
while (infileD)
{
infileD >> detainee.code >> detainee.name >> detainee.surname >>
detainee.detaineeReason >> detainee.captured >> detainee.released >> detainee.officer_code;
if (det_code == detainee.code)
{
cin.ignore();
cin.getline(detainee.code, 10);
cin.getline(detainee.name, 20);
cin.getline(detainee.surname, 20);
cin.getline(detainee.detaineeReason, 100);
cin.getline(detainee.captured, 11);
cin.getline(detainee.released, 11);
cin.getline(detainee.officer_code, 40);
}
ofstream outfileD("detaineesNEW.txt", ios::trunc);
cout << " Enter information about detainee " << endl;
// Entering information of detainee.
cin.ignore();
cout << " Code: ";
cin.getline(detainee.code, 10);
cout << " Name: ";
cin.getline(detainee.name, 20);
cout << " Surename: ";
cin.getline(detainee.surname, 20);
cout << " Reason why arested: ";
cin.getline(detainee.detaineeReason, 100);
cout << " Caputre date: ";
cin.getline(detainee.captured, 11);
cout << " Release date: ";
cin.getline(detainee.released, 11);
cout << " Captured by: ";
cin.getline(detainee.officer_code, 40);
// Writing in file.
outfileD << detainee.code << '\n';
outfileD << detainee.name << '\n';
outfileD << detainee.surname << '\n';
outfileD << detainee.detaineeReason << '\n';
outfileD << detainee.captured << '\n';
outfileD << detainee.released << '\n';
outfileD << detainee.officer_code << '\n';
outfileD << "--------------------" << '\n';
outfileD.flush();
outfileD.close();
infileD >> line;
if (strcmp(line, "--------------------") == 0)
{
entry_count++;
}
}
}
|