헤더파일(libft.h)

먼저 **libft(나만의 라이브러리)**에 들어갈 함수들을 선언해주는 헤더파일을 구현해 볼 예정입니다.


1️⃣ 헤더 파일(.h)이란?


2️⃣ #infdef를 이용한 header중복방지

(1) header 중복방지가 필요한 이유(예시)

< one.h >

**#include "two.h"**
*/* one헤더파일 코드 생략 */*

< two.h >

**#include "one.h"**
*/* two헤더파일 코드 생략 */*

< test.c >

**#include "one.h"**
int main(void)
{
	printf("Hello world!\\n");
	return (0);
}

위의 세파일을 만들고 test.c파일을 전처리 단계만을 거치면 다음과 같이 무한으로 헤더가 확장됩니다.

< 전처리 단계를 거친후 test.c >

           ...
           ...
*/* one헤더파일 코드 생략 *//* two헤더파일 코드 생략 *//* one헤더파일 코드 생략 */*...
           ...
*/* two헤더파일 코드 생략 *//* one헤더파일 코드 생략 *//* two헤더파일 코드 생략 *//* one헤더파일 코드 생략 */*int main(void)
{
	printf("Hello world!\\n");
	return (0);
}