You are on page 1of 4

//#include <stdio.h> //소스.

c
//#include "def_common.h"
//#include "naame.h"

/*
void main() //p14~15 중간 , main.c 와 cpu.c 를 주고 헤더파일을 만들어봐라 약 10 개
//(굵은글씨로 표현, 대문자) ex) #deine TRUE 1, 함수 void cpu_init( );
이런식으로 #define 4 개, 함수 2 개 #include <stdio.h> 이거 첫줄에 써야 프린트에프 가능
//

{
int cnt_num = 0;
while (TRUE)
{
cpu_init();
cpu_run();

cnt_num++;
printf("%d 회 수행완료 \n\n", cnt_num);
Sleep(1000);

}
}
*/

/*void main()
{
printf("이름: %s \n", NAME);
printf("나이: %d \n", AGE);
printf("직업 : %s \n", JOB);
}
*/

/*
#define _CPU_20M //p16 이것도 중간 나올 수 있음 p17 은 안나옴
#include <stdio.h>
#include "def_common.h"
void main()
{
printf("시스템 클락 주파수 = %d MHz \n", _CPU_CLK);
printf("타이머 설정치 = %d \n", timer_value);
}

*/

/*
#include "def_common.h" //p17

void main()
{
printf("P_Gain = %d \n", P_Gain); //20
printf("I_Gain = %d \n", I_Gain); //8
printf("D_Gain = %d \n", D_Gain); //5
}
*/

// p18 1 번만 나옴 아까 10 개중 두개가 여기서 나옴


// char , int 이런것등릐 type 을 나만의 이름으로 정의?
//회사가면 unsigned (음수 X)가 많이 볼것임
//char, int, float 이런것은 새이름 안하지만(하면 미친놈)
//unsigned char 이런거는 풀네임 귀찮아서 풀네임으로 만듬
//사진 처럼은 쓰지 말 것

/*
void main() //얜 뭐지;;
{
int cnt_num = 0;
while (TRUE)
{
cpu_init();
cpu_run();

cnt_num++;
printf("%d 회 수행완로 \n", cnt_num);
Sleep(1000);
}
}
*/

#include <stdio.h> //p19 시험 x


void init();

void main()
{
init();
init();
}

void init()
{
static int x; //static : 변수를 0 으로 초기화 , 값 유지
// 초기화 안하면 오류,

x = x + 1;
printf("x 값은 %d \n", x);
}

//a4 4 번분제 비슷하게 나옴

//def_common.h

#include <stdio.h>
#include <windows.h>

#define TRUE 1
#define NUM 5
void cpu_init();
void cpu_run();

#ifdef _CPU_20M
#define _CPU_CLK 20
#define timer_value 100
#else
#define _CPU_CLK 16
#define timer_value 125
#endif

#ifndef _CONST_H
#define _CONST_H

#define P_Gain 20
#define I_Gain 8
#define D_Gain 5
#endif

//cpu.c

#include <stdio.h>
#include "def_common.h"

void cpu_init()
{
printf("초기화 내용 \n");
}

void cpu_run()
{
int i;
for (i = 1;i<=NUM;i++)
printf("작업 수행중 \n");
}

You might also like