This website works better with JavaScript.
Home
Explore
帮助
返回水杉在线
登录水杉在线
登录水杉码园
10215501450
/
Computer-Systems-Labs
Watch
1
Star
0
Fork
0
Code
Issues
0
Pull Requests
0
Releases
0
Wiki
Activity
Browse Source
add gdb crash demo
main
zjpedu
2 years ago
parent
173608e0ac
commit
5d05e6c7fa
1 changed files
with
30 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+30
-0
lab1/test2.c
+ 30
- 0
lab1/test2.c
View File
@ -0,0 +1,30 @@
#
include
<stdio.h>
#
include
<string.h>
#
include
<stdlib.h>
char
*
buf
;
int
sum_to_n
(
int
num
)
{
int
i
,
sum
=
0
;
for
(
i
=
1
;
i
<
=
num
;
i
+
+
)
sum
+
=
i
;
return
sum
;
}
void
printSum
(
)
{
char
line
[
10
]
;
printf
(
"
enter a number:
\n
"
)
;
fgets
(
line
,
10
,
stdin
)
;
if
(
line
!
=
NULL
)
strtok
(
line
,
"
\n
"
)
;
sprintf
(
buf
,
"
sum=%d
"
,
sum_to_n
(
atoi
(
line
)
)
)
;
printf
(
"
%s
\n
"
,
buf
)
;
}
int
main
(
void
)
{
printSum
(
)
;
return
0
;
}
Write
Preview
Loading…
Cancel
Save