Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
Quiz-2
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-2
Commits
86d2f2a7
Commit
86d2f2a7
authored
Jan 22, 2025
by
정용석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strcmp - 반환 값 구분, strcpy - 함수 사용방법 주석추가
parent
7bf92264
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
Cstandard.c
+15
-4
utf8.c
+6
-1
No files found.
Cstandard.c
View file @
86d2f2a7
...
...
@@ -14,6 +14,11 @@ int my_strlen(const char *str){
return
count
;
}
/**
* src에 저장된 문자열을 dest로 복사하는 함수
* @param dest의 길이가 src의 길이보다 길어야합니다.
* @return
*/
char
*
my_strcpy
(
char
*
dest
,
const
char
*
src
){
if
(
dest
==
NULL
||
src
==
NULL
){
return
NULL
;
...
...
@@ -31,7 +36,7 @@ char *my_strcpy(char *dest, const char *src){
int
my_strcmp
(
const
char
*
str1
,
const
char
*
str2
){
if
(
str1
==
NULL
||
str2
==
NULL
){
return
-
1
;
return
-
1
00
;
// NULL 입력시 -100 반환
}
int
i
=
0
;
while
(
str1
[
i
]
==
str2
[
i
]
&&
str1
[
i
]
!=
'\0'
&&
str2
[
i
]
!=
'\0'
){
...
...
@@ -131,8 +136,10 @@ int main(void){
printf
(
"두 문자열이 같습니다.
\n
"
);
}
else
if
(
my_strcmp
(
str5
,
str6
)
==
-
1
){
printf
(
"첫 번째 문자열이 작습니다.
\n
"
);
}
else
{
}
else
if
(
my_strcmp
(
str5
,
str6
)
==
1
)
{
printf
(
"첫 번째 문자열이 큽니다.
\n
"
);
}
else
{
printf
(
"잘못된 함수 사용입니다.
\n
"
);
}
printf
(
"%s %s
\n
"
,
str6
,
str7
);
...
...
@@ -140,8 +147,10 @@ int main(void){
printf
(
"두 문자열이 같습니다.
\n
"
);
}
else
if
(
my_strcmp
(
str6
,
str7
)
==
-
1
){
printf
(
"첫 번째 문자열이 작습니다.
\n
"
);
}
else
{
}
else
if
(
my_strcmp
(
str6
,
str7
)
==
1
)
{
printf
(
"첫 번째 문자열이 큽니다.
\n
"
);
}
else
{
printf
(
"잘못된 함수 사용입니다.
\n
"
);
}
printf
(
"%s %s
\n
"
,
str7
,
str6
);
...
...
@@ -149,8 +158,10 @@ int main(void){
printf
(
"두 문자열이 같습니다.
\n
"
);
}
else
if
(
my_strcmp
(
str7
,
str6
)
==
-
1
){
printf
(
"첫 번째 문자열이 작습니다.
\n
"
);
}
else
{
}
else
if
(
my_strcmp
(
str7
,
str6
)
==
1
)
{
printf
(
"첫 번째 문자열이 큽니다.
\n
"
);
}
else
{
printf
(
"잘못된 함수 사용입니다.
\n
"
);
}
char
str3
[]
=
"Hello, WWorld! 안녕!"
;
...
...
utf8.c
View file @
86d2f2a7
...
...
@@ -39,6 +39,11 @@ int utf8_strlen(const char *str){
return
count
;
}
/**
* src에 저장된 문자열을 dest로 복사하는 함수
* @param dest의 길이가 src의 길이보다 길어야합니다.
* @return
*/
char
*
utf8_strcpy
(
char
*
dest
,
const
char
*
src
){
if
(
dest
==
NULL
||
src
==
NULL
){
return
NULL
;
...
...
@@ -56,7 +61,7 @@ char *utf8_strcpy(char *dest, const char *src){
int
utf8_strcmp
(
const
char
*
str1
,
const
char
*
str2
){
if
(
str1
==
NULL
||
str2
==
NULL
){
return
-
1
;
return
-
1
00
;
// NULL 입력시 -100 반환
}
int
i
=
0
;
while
(
str1
[
i
]
==
str2
[
i
]
&&
str1
[
i
]
!=
'\0'
&&
str2
[
i
]
!=
'\0'
){
...
...
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