FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/struct.c at master · dumin199101/framework · GitHub
dumin199101
/
framework
Public
forked from
whcyc2002/swoole_framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tests
/
struct.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (46 loc) · 941 Bytes
Breadcrumbs
framework
/
tests
/
struct.c
Copy path
File metadata and controls
49 lines (46 loc) · 941 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
40
41
42
43
44
45
46
47
48
49
//gcc -g -o struct struct.c
#include
<stdlib.h>
#include
<stdio.h>
#include
<stdint.h>
#include
<string.h>
#pragma
pack(4)
int
main
(
int
argc
,
char
*
*
argv
)
{
if
(
argc
<
2
)
{
printf
(
"./struct [filename]\n"
);
}
int
n_fread
;
if
(
argc
==
2
)
{
n_fread
=
1
;
}
else
{
n_fread
=
atoi
(
argv
[
2
]);
}
struct
{
int32_t
id
;
char
data
[
40
];
double
price
;
float
price2
;
int64_t
count
;
}
data
;
int
n
,
i
;
FILE
*
fp
;
if
(
fp
=
fopen
(
argv
[
1
],
"rb"
))
{
for
(
i
=
0
;
i
<
n_fread
;
i
++
)
{
n
=
fread
(
&
data
,
sizeof
(
data
),
1
,
fp
);
if
(
n
<
0
)
{
break
;
}
printf
(
"#%d\tid=%d\tdata=%s\tprice=%.2f\tprirce2=%.2f\tcount=%ld\n"
,
i
,
data
.
id
,
data
.
data
,
data
.
price
,
data
.
price2
,
data
.
count
);
}
}
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL