Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Dong Cao
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dong Cao
Dong Cao
Commits
60a44e04
Commit
60a44e04
authored
3 years ago
by
Dong Cao
Browse files
Options
Downloads
Patches
Plain Diff
first attempt on C subunit
parent
f515f218
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+4
-1
4 additions, 1 deletion
.gitignore
C-subunit/arithmetic.c
+44
-0
44 additions, 0 deletions
C-subunit/arithmetic.c
C-subunit/hello-world.c
+6
-0
6 additions, 0 deletions
C-subunit/hello-world.c
C-subunit/integers.dat
+10
-0
10 additions, 0 deletions
C-subunit/integers.dat
with
64 additions
and
1 deletion
.gitignore
+
4
−
1
View file @
60a44e04
...
...
@@ -11,4 +11,7 @@
*.mov
*.wmv
*.avi
*.avchd
\ No newline at end of file
*.avchd
# C exec files
*.ce
\ No newline at end of file
This diff is collapsed.
Click to expand it.
C-subunit/arithmetic.c
0 → 100644
+
44
−
0
View file @
60a44e04
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
float
take_average
(
int
sum
,
int
count
)
{
return
(
float
)
sum
/
(
float
)
count
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
FILE
*
inputFileHandle
=
NULL
;
char
inputFileName
[
128
];
int
value
=
0
;
int
sum
=
0
;
int
count
=
0
;
float
average
=
0
.
0
;
if
(
argc
<
2
)
{
printf
(
"usage: fopen <infile>
\n
"
);
exit
(
1
);
}
strcpy
(
inputFileName
,
argv
[
1
]);
if
((
inputFileHandle
=
fopen
(
inputFileName
,
"r"
))
==
NULL
)
{
fprintf
(
stderr
,
"error opening file: %s
\n
"
,
inputFileName
);
exit
(
1
);
}
while
(
fscanf
(
inputFileHandle
,
"%d"
,
&
value
)
!=
EOF
)
{
count
++
;
sum
=
sum
+
value
;
}
fclose
(
inputFileHandle
);
average
=
take_average
(
sum
,
count
);
fprintf
(
stdout
,
"file = %s, count = %d, sum = %d, average =%8.2f
\n
"
,
inputFileName
,
count
,
sum
,
average
);
return
(
0
);
}
This diff is collapsed.
Click to expand it.
C-subunit/hello-world.c
0 → 100644
+
6
−
0
View file @
60a44e04
#include
<stdio.h>
int
main
(
void
)
{
printf
(
"Hello World
\n
"
);
return
0
;
}
This diff is collapsed.
Click to expand it.
C-subunit/integers.dat
0 → 100644
+
10
−
0
View file @
60a44e04
8
10
2
0
5
38
1001
25
81
300
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
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