목록전체 글 (418)
Creative Code
#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); }
#include #include void my_srand(int); // function declaration 함수 선언(미리 선언을 해두면 main 함수 밑에 함수를 쓰거나 다른.c파일에 분리를 하더라도 참조할 수 있다. int my_rand(void); int main(void) { my_srand(time(NULL)); for (int i = 1; i
#include #include int seed; void my_srand(int s) { seed = s; } int my_rand(void) { seed = 1103515245 * seed +12345; return ((unsigned)(seed/65536)%32768); } int main(void) { my_srand(time(NULL)); for (int i = 1; i