Notice
Recent Posts
Recent Comments
Creative Code
main.c(date) 본문
※main.c파일
//#include <stdio.h> main함수에 printf함수가 없어서 필요없음
#include "date.h"
/* typedef 사용법
typedef unsigned long size_t; // unsigned long 을 size_t로 정의
size_t len; // -> unsigned long len과 같은말
typedef signed char int_8;
typedef short int_16;
typedef int int_32;
typedef long long int_64;
int_8 i;
int_16 i2;
int_32 i3;
int_64 i4;
*/
int main(void)
{
Date today;
today.year = 2023;
today.month = 8;
today.day = 4;
Date birthday = {2005,8,2};
printDate(&today);
printDate(&birthday);
return 0;
}
※date.h파일
#ifndef DATE_H
#define DATE_H
typedef struct date { // 구조체의 정의는 헤더파일에 쓴다.
int year;
int month;
int day;
} Date;
void printDate(const Date *pd);
#endif
※date.c파일
#include <stdio.h>
#include "date.h"
void printDate(const Date *pd)
{
//printf("(%d/%d/%d)\n",(*pd).year,(*pd).month,(*pd).day);
printf("(%d/%d/%d)\n",pd->year, pd->month, pd->day);
}
'C Programming' 카테고리의 다른 글
name.c(scanf로 문자열 입력받기) (0) | 2023.08.07 |
---|---|
main.c(구조체- 좌표) (0) | 2023.08.04 |
main.c(구조체) (0) | 2023.08.04 |
main.c(serial함수) (0) | 2023.08.04 |
main.c(rand함수) (0) | 2023.08.04 |