blob: 910e8a1ec03c9ac10b169a2ddbbdf024b28acc05 (
plain) (
blame)
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
|
#include <iostream>
#include <fstream>
using namespace std;
const size_t capacity = 1024;
enum class Spec
{
computerScience,
softEng
};
struct StudentRecord
{
char firstName[capacity];
char lastName[capacity];
char fnRaw[capacity];
Spec spec;
int fn;
char email[capacity];
};
struct StudentCollection
{
StudentRecord* data;
};
size_t getLinesCount(const char* fileName)
{
ifstream file(fileName);
if (!file.is_open())
return 0;
size_t count = 0;
while (!file.eof())
{
char buff[capacity];
file.getline(buff, capacity);
count++;
}
file.close ();
return count;
}
int main()
{
char inputFileName[] = "lists/si.csv";
size_t studentsCount = getLinesCount(inputFileName) - 1;
StudentCollection myCollection;
myCollection.data = new StudentRecord[studentsCount];
//parse
//...
delete[] myCollection.data;
}
|