일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- 오픈소스
- 주를 기뻐하라
- 스크립트
- 쉘
- 크로스와이어
- 하늘
- sword project
- 우분투
- STEP bible
- 리눅스
- 파이선
- 주를기뻐하라
- 회중찬양
- 시포스
- sh
- Bash
- 성경 주해
- xiphos
- 쉘스크립트
- 소드 프로젝트
- 파이썬
- 아이폰
- noti
- 이메일 노티
- 게시판 감시
- 성서 주석
- crosswire
- 사진
- Python
- NET bible
- Today
- Total
저 세상밖으로...
변수 본문
:: C의 변수 형태 ::
- 32비트 기준 -
문자형 | ![]() | 1 Bytes | ![]() |
![]() | ![]() | 2 Bytes | ![]() |
![]() | 4 Bytes | ![]() ![]() | |
![]() | 4 Bytes | ![]() ![]() | |
![]() | ![]() | 1 Bytes | ![]() |
![]() | ![]() | 2 Bytes | ![]() |
![]() | 4 Bytes | ![]() | |
![]() | 4 Bytes | ![]() | |
![]() | ![]() | 4 Bytes | ![]() |
![]() | 8 Bytes | ![]() | |
![]() | ![]() | 0 Bytes | ![]() |
여러가지 형태의 변수 크기를 출력하는 소스
________________________________________
/* 바이트 단위로 C 형 변수의 크기를 구하는 소스 */
#include <stdio.h>
main()
{
printf("\n A char is %d bytes", sizeof( char ));
printf("\n An int is %d bytes", sizeof( int ));
printf("\n A short is %d bytes", sizeof( short ));
printf("\n A long is %d bytes", sizeof( long ));
printf("\n An unsigned char is %d bytes", sizeof( unsigned char ));
printf("\n An unsigned int is %d bytes", sizeof( unsigned int ));
printf("\n An unsigned short is %d bytes", sizeof( unsigned short ));
printf("\n An unsigned long is %d bytes", sizeof( unsigned long ));
printf("\n A float is %d bytes", sizeof( float ));
printf("\n A double is %d bytes", sizeof( double ));
return 0;
}
__________________________________________
결과는...
A char is 1 bytes
An int is 4 bytes
A short is 2 bytes
A long is 4 bytes
An unsigned char is 1 bytes
An unsigned int is 4 bytes
An unsigned short is 2 bytes
An unsigned long is 4 bytes
A float is 4 bytes
A double is 8 bytes
int가 4바이트가 잡힌다. 16비트 컴퓨터와는 다른듯.(무려 16비트 시절의 내용!!)
:: 상수를 선언하는 두 가지 방법 ::
#define PI 3.14159
const int count = 100;
#define 지시어로 생성되는 기호 상수와 const 키워드를 통해서 정의되는 기호 상수는 '포인터와 변수 범위'와 관련하여서 차이가 생긴다.
[참고 문헌]
Teach yourself C
* 자료형 크기 관련
http://foxlime.tistory.com/115
'프로그래밍 > C언어' 카테고리의 다른 글
함수(function) (0) | 2016.05.07 |
---|---|
문장(Statement), 수식(expression), 연산자(operator) (0) | 2016.05.06 |