Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
magicCards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eray Düzenli
magicCards
Commits
7ab6a749
Commit
7ab6a749
authored
2 years ago
by
Eraser
Browse files
Options
Downloads
Patches
Plain Diff
Aufgabe 5 done
parent
0a121e66
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
functions.cpp
+27
-0
27 additions, 0 deletions
functions.cpp
functions.h
+1
-0
1 addition, 0 deletions
functions.h
main.cpp
+2
-0
2 additions, 0 deletions
main.cpp
with
30 additions
and
0 deletions
functions.cpp
+
27
−
0
View file @
7ab6a749
...
@@ -86,4 +86,31 @@ void saveCardsToFile(const std::list<Cards>& cardsList) {
...
@@ -86,4 +86,31 @@ void saveCardsToFile(const std::list<Cards>& cardsList) {
file
.
close
();
file
.
close
();
}
}
//Aufgabe 5
std
::
list
<
std
::
string
>
referenceNames
(
const
std
::
string
&
referenceFile
)
{
std
::
ifstream
file
(
referenceFile
);
//check if file can be opened
if
(
!
file
)
{
throw
std
::
runtime_error
(
"Error: Unable to open file "
+
referenceFile
);
}
//output
std
::
list
<
std
::
string
>
namesList
;
//temp for names
std
::
string
name
;
//read every line
while
(
std
::
getline
(
file
,
name
))
{
namesList
.
push_back
(
name
);
}
//close file
file
.
close
();
//for testing reasons
std
::
cout
<<
namesList
.
front
()
<<
std
::
endl
;
std
::
cout
<<
namesList
.
back
()
<<
std
::
endl
;
return
namesList
;
}
This diff is collapsed.
Click to expand it.
functions.h
+
1
−
0
View file @
7ab6a749
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
std
::
list
<
Cards
>
getListOfCards
(
const
std
::
string
&
filename
);
std
::
list
<
Cards
>
getListOfCards
(
const
std
::
string
&
filename
);
void
saveCardsToFile
(
const
std
::
list
<
Cards
>&
CardsList
);
void
saveCardsToFile
(
const
std
::
list
<
Cards
>&
CardsList
);
std
::
list
<
std
::
string
>
referenceNames
(
const
std
::
string
&
referenceFile
);
...
...
This diff is collapsed.
Click to expand it.
main.cpp
+
2
−
0
View file @
7ab6a749
...
@@ -25,6 +25,8 @@ int main() {
...
@@ -25,6 +25,8 @@ int main() {
test
=
getListOfCards
(
"/Users/erayduzenli/CLionProjects/magicCards/scrambled.txt"
);
test
=
getListOfCards
(
"/Users/erayduzenli/CLionProjects/magicCards/scrambled.txt"
);
//TODO why does it save the file in the debug folder
//TODO why does it save the file in the debug folder
saveCardsToFile
(
test
);
saveCardsToFile
(
test
);
referenceNames
(
"/Users/erayduzenli/CLionProjects/magicCards/reference.txt"
);
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment