Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Python
- Cleancode
- 인프런
- web
- DP
- BASIC
- Algorithm
- server
- C
- sorting
- 따라하면서 배우는 C언어
- JavaScript
- BOJ
- greedy
- Math
- udemy
- 따배씨
- String
- php
- BFS
- 따라하며 배우는 C언어
- 정수론
- dfs
- Algospot
- 종만북
- programmers
- 생활코딩
- C언어
- 백준
- graph
Archives
- Today
- Total
몽상실현개발주의
[따배씨] 9.11 헤더 파일 만들기 본문
따배씨 - 따라하며 배우는 C언어
9강 함수
9.11 헤더 파일 Header Files 만들기
- 헤더 파일을 만들어서 코드를 여러개의 파일로 분리하여 반복사용하는 것이 효율적
#include <stdio.h>
void print_hello(){
printf("Hello\n");
}
void print_hi(){
printf("Hi\n");
}
void print_str(char* str){
printf("%s\n", str);
}
int main(){
print_hello();
print_hi();
print_hello();
print_hi();
print_str("No one lives forever.");
print_str("Valar morghulis");
return 0;
}
#include <stdio.h>
#include "my_print_functions.h"
int main(){
print_hello();
print_hi();
print_hello();
print_hi();
print_str("No one lives forever.");
print_str("Valar morghulis");
printf("Hello");
return 0;
}
- main.c
- include 된 header 파일에 stdio.h 가 include 되었지만, main.c 에서 printf 함수를 사용 하려면 stdio.h 헤더를 다시 include 해주어야함
- header 파일에 include 한것은 파일 범위에서만 유효
#fndef my_print_functions_h
#define my_print_functions_h
void print_hello(void);
void print_hi(void);
void print_str(char* str);
#endif /* my_print_functions_h */
- my_print_functions.h
- prototype 선언
#include "my_print_functions.h"
#include <stdio.h>
void print_hello(){
printf("Hello\n");
}
void print_hi(){
printf("Hi\n");
}
void print_str(char* str){
printf("%s\n", str);
}
- my_print_function.c
- header 파일에 prototype을 선언한 함수를 작성
이 글의 모든 사진과 내용의 출처는 홍정모 교수님께 있음을 알려드립니다.
http://blog.naver.com/atelierjpro
실리콘 밸리의 프로그래머 : 네이버 블로그
안녕하세요! 홍정모 블로그에 오신 것을 환영합니다. 주로 프로그래밍 관련 메모 용도로 사용합니다. 강의 수강하시는 분들은 홍정모 연구소 카페로 오세요.
blog.naver.com
http://www.inflearn.com/course/following-c
홍정모의 따라하며 배우는 C언어 - 인프런 | 강의
'따배씨++'의 성원에 힘입어 새롭게 개발된 C 언어로 시작하는 프로그래밍 입문 강의입니다. '따배씨'와 함께 프로그래밍 인생을 업그레이드 해보세요., 따라하며 배우는 C언어 '따배씨++'의 성원
www.inflearn.com
'Language > C' 카테고리의 다른 글
[따배씨] 9.13 포인터의 기본적인 사용 방법 (0) | 2021.06.03 |
---|---|
[따배씨] 9.12 포인터 Pointer 의 작동 원리 (0) | 2021.06.03 |
[따배씨] 9.10 피보나치 예제와 재귀 호출의 장단점 (0) | 2021.05.30 |
[따배씨] 9.9 이진수 변환 예제 (0) | 2021.05.30 |
[따배씨] 9.8 팩토리얼 예제 (0) | 2021.05.30 |
Comments