More actions
변수의 영역
전역 변수 - 해당 파일 내에서 유효함 (외부 참조 가능), BSS 세그먼트의 공간 사용 지역 변수 - 해당 블럭 내에서 유효함 static 전역 변수 - 해당 파일 내에서 유효함 (외부 참조 불가능)
변수의 기억 부류 지정
변수의 기억 장소 선택
register - CPU 레지스터를 변수로 할당 auto - 스택 공간을 변수로 할당 static - BSS 세그먼트의 공간을 변수로 할당 extern - 외부 변수 참조
const 키워드
const int a; int const b; const int *c; int * const d; const int * const e;
volatile 키워드
#include <stdio.h>
#include <time.h>
void main()
{
clock_t start, finish;
double duration;
start = clock();
volatile int a = 10, b = 20, c;
for(int i = 0 ; i < 1000000000 ; i++)
c = a * b;
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf("%2.1f seconds\n", duration);
}