FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
StringNAndBlockStream/BlockStreamAndStringNDriver.cpp at master · AmitSna/StringNAndBlockStream · GitHub
AmitSna
StringNAndBlockStream
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
StringNAndBlockStream
/
BlockStreamAndStringNDriver.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (30 loc) · 855 Bytes
Breadcrumbs
StringNAndBlockStream
/
BlockStreamAndStringNDriver.cpp
Copy path
File metadata and controls
39 lines (30 loc) · 855 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
BlockStreamAndStringNDriver.cpp
Escribe y lee archivo de registros con cadenas de tamaño acotado,
muestra los empleados con legajo mayor a 10.
2015-11-08 - 2018-06-30
Esp. Ing. José María Sola
Profesor
UTN FRBA
*/
#
include
<
iostream
>
#
include
"
BlockStream.h
"
#
include
"
StringN.h
"
int
main
(){
struct
Person
{
int
id;
String<
25
> name;
//
instead of string name;
};
constexpr
auto
filename{
"
people
"
};
std::ofstream out{filename, std::ios::binary};
WriteBlock
(out, Person{
10
,
PackString
(
"
Bruce
"
)});
//
Wayne
WriteBlock
(out, Person{
11
,
PackString
(
"
Clark
"
)});
//
Kent
WriteBlock
(out, Person{
12
,
PackString
(
"
Joseph
"
)});
//
Dredd
out.
close
();
std::ifstream in{filename, std::ios::binary};
for
(Person p;
ReadBlock
(in, p); )
if
( p.
id
>
10
)
std::cout
<< p.
id
<<
"
,
"
<<
UnpackString
(p.
name
)
<<
'
\n
'
;
in.
close
();
}
Back
|
FazBrowse Home
|
New Git URL