학습 내용 : strcpy() 함수의 내부적인 흐름을 학습합니다.
소스 코드 :
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
|
#include <stdio.h>
#include <string.h>
#define KOREA "대한민국"
char* My_strcpy(char* dest, const char* src);
void main()
{
char string[100];
My_strcpy(string, KOREA);
puts(string);
}
char* My_strcpy(char* dest, const char* src)
{
if (dest == (int)NULL || src == (int)NULL)
{
if (*dest != (int)NULL)
{
*dest = (int)NULL;
}
return NULL;
}
do
{
*dest++ = *src;
} while (*src++ != (int)NULL);
return dest;
}
|
실행 화면 :
'프로그래밍 > C언어 300제' 카테고리의 다른 글
중급 60. 문자열을 비교하는 함수 만들기 (0) | 2020.02.17 |
---|---|
중급 59. 문자열을 대.소문자로 구분하여 비교하기 (strcmp) (0) | 2020.02.17 |
중급 57. 문자열 복사하기(strcpy) (0) | 2020.02.17 |
중급 56. 문자열 출력하기 (puts) (0) | 2020.02.17 |
중급 55. 문자열 입력받기 (gets) (0) | 2020.02.17 |
트랙백 , 댓글 가 달렸습니다.