목록전체 글 (402)
Creative Code
※main.c파일 #include #include "point.h" int main(void) { point Point; int x1; int y1; printf("점의 x좌표 : "); scanf("%d",&x1); printf("점의 y좌표 : "); scanf("%d",&y1); Point.x = x1; Point.y = y1; printPoint(&Point); getLength(&Point); return 0; } ※point.h파일 #ifndef POINT_H #define POINT_H typedef struct point { int x; int y; }point; void printPoint(const point *p); void getLength(const point *q); #endif..
※main.c파일 //#include 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 =..
#include struct date { int year; int month; int day; }; void printDate(struct date d) { printf("%d년 %d월 %d일 \n",d.year, d.month, d.day); } int main(void) { //birthday /* int birthday_year, birthday_month, birthday_day; birthday_year = 2005; birthday_month = 8; birthday_day =2; */ struct date birthday; birthday.year = 2005; birthday.month = 8; birthday.day = 2; /* int today_year, today_month, tod..
※main.c파일 #include #include "serial.h" int main(void) { for (int i = 1; i
※main.c 파일 #include #include // user의 헤더파일을 가져올 때 #include "rand.h" // 같은 디렉토리 안에 있는 헤더파일을 가져올 때 int main(void) { my_srand(time(NULL)); for (int i = 1; i my_stand함수와 my_rand함수만 접근이 가능하다. // -> 허용된 연산을 통해서만 데이터에 접근하게 할 때 사용(직접적으로 접근x) void my_srand(int s) // function definition { seed = s; } int my_rand(void) { seed = 1103515245 * seed +12345; return ((unsigned)(seed/65536)%32768); }