Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
Quiz-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
정용석
Quiz-1
Commits
f7e04d15
Commit
f7e04d15
authored
Jan 17, 2025
by
정용석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Null 포인터 입력처리
parent
6537d9d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
quiz6.cpp
+12
-7
No files found.
quiz6.cpp
View file @
f7e04d15
#include <stdio.h>
#include <stdlib.h>
unsigned
int
my_strlen
(
char
*
s
){
unsigned
int
my_strlen
(
c
onst
c
har
*
s
){
unsigned
int
i
=
0
;
while
(
s
[
i
]
!=
'\0'
){
i
++
;
...
...
@@ -10,17 +10,22 @@ unsigned int my_strlen(char *s){
return
i
;
}
void
my_strcpy
(
char
*
s1
,
char
*
s2
)
{
if
(
my_strlen
(
s1
)
<=
my_strlen
(
s2
)){
char
*
my_strcpy
(
char
*
dest
,
const
char
*
src
){
if
(
dest
==
NULL
||
src
==
NULL
){
return
NULL
;
}
if
(
sizeof
(
dest
)
<
my_strlen
(
src
)){
printf
(
"Error : 첫 번째 인자의 배열의 크기가 두 번째 인자의 크기보다 작기 때문에 정상적인 복사가 되지않습니다.
\n
"
);
return
;
return
NULL
;
}
int
i
=
0
;
while
(
s2
[
i
]
!=
'\0'
){
s1
[
i
]
=
s2
[
i
];
while
(
src
[
i
]
!=
'\0'
){
dest
[
i
]
=
src
[
i
];
i
++
;
}
s1
[
i
]
=
'\0'
;
dest
[
i
]
=
'\0'
;
return
dest
;
}
int
main
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment