-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcity.cpp
More file actions
60 lines (55 loc) · 1.26 KB
/
city.cpp
File metadata and controls
60 lines (55 loc) · 1.26 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
#include "city.h"
#include <fstream>
extern void GetCityIdNo();
extern void SetCityIdNo();
extern int cityIdNo;
extern int cityCount;
City::City()
{
setstateId(0);
setSeats(0);
LeadcandidateId = 0;
setstateName("NoName");
strcpy(cityName, "NoName");
cityId = 0;
}
int City::getCityInfo(int sId, const char *sName)
{
setstateId(sId);
setstateName(sName);
std::cout << "Enter the Name : ";
std::cin.getline(cityName, 24);
cityCount++;
int s = 1;
setSeats(s);
GetCityIdNo();
cityId = ++cityIdNo;
SetCityIdNo();
LeadcandidateId = 0;
return s;
}
void City::getCity(int x)
{
int i = 0;
std::ifstream finCityRecord;
finCityRecord.open("Cities.txt", std::ios::in | std::ios::binary);
if (!finCityRecord)
{
std::cout << "\n File not Found";
}
else
{
while (!finCityRecord.eof() && i != x + 1)
{
finCityRecord.read((char *)this, sizeof(*this));
i++;
}
}
}
void City::storeCity()
{
std::ofstream foutCity;
foutCity.open("Cities.txt", std::ios::app | std::ios::binary);
foutCity.write(reinterpret_cast<char *>(this), sizeof(*this));
foutCity.close();
}