-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOFile.cpp
More file actions
65 lines (43 loc) · 1.41 KB
/
IOFile.cpp
File metadata and controls
65 lines (43 loc) · 1.41 KB
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
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
int loadSystem();
void writeAllFiles(int numOfElements);
//Limbs
int addFile(int numOfElements, string temp);
string indvElements[1000];
int numberOfElements = loadSystem();
int loadSystem(){ //---------------------LOAD FILES
int index = 0;
ifstream open_data; //File stream - input.
open_data.open("mylog.txt");
while(!(open_data.eof())) //loop for "Load data" function - return numOfElements
{
getline(open_data, indvElements[index]);
index++;
}
//Switch for addFile function(Adds 1 extra string to array when first item is created, second time does not create extra variable).
return index;
}
void writeAllFiles(int numOfElements){ //-------------------SAVE FILE
ofstream data_out;
data_out.open("mylog.txt");
int index;
for (index=0; index < numOfElements; index++){
data_out << indvElements[index] << endl;
}
}
int addFile(int numOfElements, string temp){
indvElements[numOfElements - 1 ] = temp;
cout << "Enter name of File: ";
cin >> indvElements[numOfElements];
cout << "item in array nunber: " << numOfElements << " Value is " << indvElements[numOfElements] << endl;
writeAllFiles(numOfElements);
}
int main(){
while(1){
addFile(numberOfElements, indvElements[numberOfElements - 1 ]); // Add File
numberOfElements++;
}
}