unable to ru

When I run the code, the program tell me that it is unable to open the three files.
Can anyone help me please?

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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <map>

using namespace std;

struct local {
  int CODArtigoAM;
  int Corredor;
  int Bastidor;
  int LugarPicking;
};

struct encomenda {
  int Data;
  int CodArtigoAM;
  int CODLocalAM;
  int Junho2018;
};

struct cai {
int LojaID;
int Cais;
int ZonaCais;
int NRetans_4;
int NRetans_3;
int NRetans_2;
int NRetans_1;
int NRetans1;
int NRetans2;
int NRetans3;
int NRetans4;
int NRetans5;
int NRetans6;
int NRetans7;
int NRetans8;
int NRetans9;
int NRetans10;
int NRetans11;
};

vector<string> readFile(string file) {
  vector<string> array;
  string line;

  ifstream myFile (file.c_str());

  if (myFile.is_open()) {
    while ( getline(myFile, line) ) {
      array.push_back(line);
    }
    myFile.close();
  } else {
    cout << "Unable to open file: " << file;
  }

  return array;
}

vector<int> splitLine(string str, char delimiter) {
  replace(str.begin(), str.end(), delimiter, ' ');

  vector<int> array;
  stringstream ss(str);
  int temp;

  while (ss >> temp) {
    array.push_back(temp);
  }

  return array;
}

local createlocal (int CODArtigoAM, int Corredor, int Bastidor, int LugarPicking) {
  local temp;

  temp.CODArtigoAM = CODArtigoAM;
  temp.Corredor = Corredor;
  temp.Bastidor = Bastidor;
  temp.LugarPicking = LugarPicking;

  return temp;
}

encomenda createEncomenda(int Data, int CodArtigoAM, int CODLocalAM, int Junho2018) {
  encomenda temp;

  temp.Data = Data;
  temp.CodArtigoAM = CodArtigoAM;
  temp.CODLocalAM= CODLocalAM;
  temp. Junho2018= Junho2018;

  return temp;
}
cai createcai(int LojaID, int Cais, int ZonaCais, int NRetans_4, int NRetans_3, int NRetans_2, int NRetans_1, int NRetans1, int NRetans2, int NRetans3, int NRetans4, int NRetans5, int NRetans6, int NRetans7, int NRetans8, int NRetans9, int NRetans10, int NRetans11) {
  cai temp;

  temp.LojaID = LojaID;
  temp.Cais = Cais;
  temp.ZonaCais= ZonaCais;
  temp.NRetans_4= NRetans_4;
  temp.NRetans_3= NRetans_3;
  temp.NRetans_2= NRetans_2;
  temp.NRetans_1= NRetans_1;
  temp.NRetans1= NRetans1;
  temp.NRetans2= NRetans2;
  temp.NRetans3= NRetans3;
  temp.NRetans4= NRetans4;
  temp.NRetans5= NRetans5;
  temp.NRetans6= NRetans6;
  temp.NRetans7= NRetans7;
  temp.NRetans8= NRetans8;
  temp.NRetans9= NRetans9;
  temp.NRetans10= NRetans10;
  temp.NRetans11= NRetans11;
  return temp;
}

vector<encomenda> readEncomendas() {
  vector<string> encomendasFile = readFile("Encomendas.txt");
  vector<encomenda> encomendas;

  for (int i=1; i < encomendasFile.size(); i++){
    vector<int> line = splitLine(encomendasFile[i], ';');

    encomenda newEncomenda = createEncomenda(line[0], line[1], line[2], line[3]);
    encomendas.push_back(newEncomenda);
  }

  return encomendas;
}

vector<local> readLocais() {
  vector<string> locaisFile = readFile("Locais.txt");
  vector<local> locais;

  for (int i=1; i < locaisFile.size(); i++){
    vector<int> line = splitLine(locaisFile[i], ';');
    local newLocal = createlocal(line[0], line[1], line[2], line[3]);
    locais.push_back(newLocal);
  }
    return locais;
 }
vector<cai> readcais() {
  vector<string> caisFile = readFile("Cais.txt");
  vector<cai> cais;

  for (int i=1; i < caisFile.size(); i++){
    vector<int> line = splitLine(caisFile[i], ';');
    cai newCai = createcai(line[0], line[1], line[2], line[3], line[4], line[5], line[6], line[7], line[8], line[9], line[10], line[11], line[12] , line[13], line[14], line[15], line[16], line[17]);
    cais.push_back(newCai);
  }
    return cais;
 }

int main () {

  vector<encomenda> encomendas = readEncomendas();
  vector<local> locais = readLocais();
  vector<cai> cais = readcais();

return 0;
}
put the files on the working directory
or use absolute paths
thanks! I had the files on a contentfolder . It works now
Topic archived. No new replies allowed.