Skip to content

Commit c51051f

Browse files
committed
Fstream
Fstream task in C++
1 parent 85267b4 commit c51051f

File tree

10 files changed

+339
-0
lines changed

10 files changed

+339
-0
lines changed
25 KB
Binary file not shown.
Binary file not shown.

FstreamTask/FstreamTask/Applier.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
class Applier {
4+
public:
5+
6+
string _name = "";
7+
int _age = 0;
8+
string _speciality = "";
9+
string _text = "";
10+
11+
Applier() = default;
12+
Applier(string name, int age, string specialty, string text) {
13+
_name = name;
14+
_age = age;
15+
_speciality = specialty;
16+
_text = text;
17+
}
18+
19+
string getName() { return _name; }
20+
int getAge() { return _age; }
21+
string getSpeciality() { return _speciality; }
22+
string getText() { return _text; }
23+
24+
void cv()
25+
{
26+
cout << "Name: " << _name << endl;
27+
cout << "Age: " << _age << endl;
28+
cout << "Speciality: " << _speciality << endl;
29+
cout << "Text: " << _text << endl;
30+
31+
}
32+
33+
};

FstreamTask/FstreamTask/Company.h

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#pragma once
2+
3+
4+
class Company {
5+
vector<Applier*> appliers;
6+
7+
public:
8+
void hireUp(Applier* cv) {
9+
for (size_t i = 0; i < appliers.size(); i++)
10+
{
11+
appliers.push_back(cv);
12+
}
13+
}
14+
15+
void showAllCV() {
16+
17+
for (size_t i = 0; i < appliers.size(); i++) {
18+
appliers[i]->cv();
19+
}
20+
}
21+
22+
23+
void writeToFile(string filename) {
24+
ofstream fout(filename, ios::app);
25+
if (!fout)
26+
throw new exception("File can not created");
27+
if (!fout.is_open()) {
28+
fout.close();
29+
throw new exception("File can not opened");
30+
}
31+
fout << "CV Info:" << endl;
32+
for (size_t i = 0; i < appliers.size(); i++) {
33+
34+
fout << "Name: " << appliers[i]->getName() << endl;
35+
fout << "Age: " << appliers[i]->getAge() << endl;
36+
fout << "Speciality: " << appliers[i]->getSpeciality() << endl;
37+
fout << "Text: " << appliers[i]->getText() << endl;
38+
39+
}
40+
fout.close();
41+
42+
}
43+
friend istream& operator>>(istream& input, Applier& apilliers);
44+
45+
void readToFile(string filename) {
46+
ifstream fin("myFile.txt", ios::in);
47+
48+
if (!fin)
49+
throw exception("File can not find");
50+
51+
if (!fin.is_open()) {
52+
fin.close();
53+
throw exception("File can not opened");
54+
}
55+
56+
57+
58+
59+
while (!fin.eof()) {
60+
Applier a;
61+
for (size_t i = 0; i < appliers.size(); i++) {
62+
63+
fin >> a.getName();
64+
fin >> a.getAge();
65+
fin >> a.getSpeciality();
66+
fin >> a.getText();
67+
}
68+
}
69+
70+
71+
fin.close();
72+
}
73+
74+
75+
};
76+
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
using namespace std;
3+
#include<fstream>
4+
#include<vector>
5+
#include<string>
6+
#include "Applier.h"
7+
#include "Company.h"
8+
9+
10+
11+
int main() {
12+
Applier* cv1 = new Applier("Huseyn", 18, "IT", "Empty1");
13+
Applier* cv2 = new Applier("Huseyn", 18, "Design", "Empty2");
14+
15+
16+
Company company;
17+
company.hireUp(cv1);
18+
company.hireUp(cv2);
19+
20+
company.writeToFile("company.txt");
21+
22+
company.showAllCV();
23+
24+
company.readToFile("company.txt");
25+
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Kaynak Dosyalar">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Üst Bilgi Dosyaları">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Kaynak Dosyaları">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="ConsoleApplication55.cpp">
19+
<Filter>Kaynak Dosyalar</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="Company.h">
24+
<Filter>Kaynak Dosyalar</Filter>
25+
</ClInclude>
26+
<ClInclude Include="Applier.h">
27+
<Filter>Kaynak Dosyalar</Filter>
28+
</ClInclude>
29+
</ItemGroup>
30+
</Project>
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>
+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{730a87be-0fbf-4515-9b2a-ebc635c7f41d}</ProjectGuid>
25+
<RootNamespace>ConsoleApplication55</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<SDLCheck>true</SDLCheck>
77+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
<Link>
81+
<SubSystem>Console</SubSystem>
82+
<GenerateDebugInformation>true</GenerateDebugInformation>
83+
</Link>
84+
</ItemDefinitionGroup>
85+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
86+
<ClCompile>
87+
<WarningLevel>Level3</WarningLevel>
88+
<FunctionLevelLinking>true</FunctionLevelLinking>
89+
<IntrinsicFunctions>true</IntrinsicFunctions>
90+
<SDLCheck>true</SDLCheck>
91+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<ConformanceMode>true</ConformanceMode>
93+
</ClCompile>
94+
<Link>
95+
<SubSystem>Console</SubSystem>
96+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
97+
<OptimizeReferences>true</OptimizeReferences>
98+
<GenerateDebugInformation>true</GenerateDebugInformation>
99+
</Link>
100+
</ItemDefinitionGroup>
101+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
102+
<ClCompile>
103+
<WarningLevel>Level3</WarningLevel>
104+
<SDLCheck>true</SDLCheck>
105+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106+
<ConformanceMode>true</ConformanceMode>
107+
</ClCompile>
108+
<Link>
109+
<SubSystem>Console</SubSystem>
110+
<GenerateDebugInformation>true</GenerateDebugInformation>
111+
</Link>
112+
</ItemDefinitionGroup>
113+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
114+
<ClCompile>
115+
<WarningLevel>Level3</WarningLevel>
116+
<FunctionLevelLinking>true</FunctionLevelLinking>
117+
<IntrinsicFunctions>true</IntrinsicFunctions>
118+
<SDLCheck>true</SDLCheck>
119+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120+
<ConformanceMode>true</ConformanceMode>
121+
</ClCompile>
122+
<Link>
123+
<SubSystem>Console</SubSystem>
124+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
125+
<OptimizeReferences>true</OptimizeReferences>
126+
<GenerateDebugInformation>true</GenerateDebugInformation>
127+
</Link>
128+
</ItemDefinitionGroup>
129+
<ItemGroup>
130+
<ClCompile Include="ConsoleApplication55.cpp" />
131+
</ItemGroup>
132+
<ItemGroup>
133+
<ClInclude Include="Applier.h" />
134+
<ClInclude Include="Company.h" />
135+
</ItemGroup>
136+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
137+
<ImportGroup Label="ExtensionTargets">
138+
</ImportGroup>
139+
</Project>

FstreamTask/FstreanTask.sln

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32616.157
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication55", "ConsoleApplication55\ConsoleApplication55.vcxproj", "{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Debug|x64.ActiveCfg = Debug|x64
17+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Debug|x64.Build.0 = Debug|x64
18+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Debug|x86.ActiveCfg = Debug|Win32
19+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Debug|x86.Build.0 = Debug|Win32
20+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Release|x64.ActiveCfg = Release|x64
21+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Release|x64.Build.0 = Release|x64
22+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Release|x86.ActiveCfg = Release|Win32
23+
{730A87BE-0FBF-4515-9B2A-EBC635C7F41D}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {5DEA116D-0C81-46F2-8F91-79CEEA0A46B7}
30+
EndGlobalSection
31+
EndGlobal

0 commit comments

Comments
 (0)