상용되는 특수 목적 유형:
변하기 쉬운 유형 |
묘사 |
size_t |
바이트에 있는 목표의 크기 저장을 위해 이용되는 서명 없는 유형 |
time_t |
시간 () 기능의 결과를 저장했었다 |
clock_t |
시계 () 기능의 결과를 저장했었다 |
FILE |
시내 접근을 위해 사용하는 (보통 파일 또는 장치) |
ptrdiff_t |
2개의 포인터 사이 다름의 서명된 유형 |
div_t |
DIV () 기능의 결과를 저장했었다 |
ldiv_t |
ldiv () 기능의 결과를 저장했었다 |
fpos_t |
파악 파일 위치 정보에 사용했다 |
va_list |
변하기 쉬운 논쟁 취급에서 사용하는 |
wchar_t |
(장시간 문자집합에 사용되는) 넓은 문자형 |
sig_atomic_t |
신호 다루개에서 사용하는 |
Jmp_buf |
국소적이 아닌 점프를 위해 사용하는 |
잘 이해하기 위하여 이 가변은 저희가 보기를 가지고 가게 했다:
/* C 가변의 바이트에 있는 범위 그리고 크기를 말하는 프로그램 */
#include <stdio.h>
int main()
{
int a; /* simple integer type */
long int b; /* long integer type */
short int c; /* short integer type */
unsigned int d; /* unsigned integer type */
char e; /* character type */
float f; /* floating point type */
double g; /* double precision floating point */
a = 1023;
b = 2222;
c = 123;
d = 1234;
e = 'X';
f = 3.14159;
g = 3.1415926535898;
printf( "\nA char is %d bytes", sizeof( char ));
printf( "\nAn int is %d bytes", sizeof( int ));
printf( "\nA short is %d bytes", sizeof( short ));
printf( "\nA long is %d bytes", sizeof( long ));
printf( "\nAn unsigned char is %d bytes",
sizeof( unsigned char ));
printf( "\nAn unsigned int is %d bytes",
sizeof( unsigned int ));
printf( "\nAn unsigned short is %d bytes",
sizeof( unsigned short ));
printf( "\nAn unsigned long is %d bytes",
sizeof( unsigned long ));
printf( "\nA float is %d bytes", sizeof( float ));
printf( "\nA double is %d bytes\n", sizeof( double ));
printf("a = %d\n", a); /* decimal output */
printf("a = %o\n", a); /* octal output */
printf("a = %x\n", a); /* hexadecimal output */
printf("b = %ld\n", b); /* decimal long output */
printf("c = %d\n", c); /* decimal short output */
printf("d = %u\n", d); /* unsigned output */
printf("e = %c\n", e); /* character output */
printf("f = %f\n", f); /* floating output */
printf("g = %f\n", g); /* double float output */
printf("\n");
printf("a = %d\n", a); /* simple int output */
printf("a = %7d\n", a); /* use a field width of 7 */
printf("a = %-7d\n", a); /* left justify in
field of 7 */
c = 5;
d = 8;
printf("a = %*d\n", c, a); /* use a field width of 5*/
printf("a = %*d\n", d, a); /* use a field width of 8 */
printf("\n");
printf("f = %f\n", f); /* simple float output */
printf("f = %12f\n", f); /* use field width of 12 */
printf("f = %12.3f\n", f); /* use 3 decimal places */
printf("f = %12.5f\n", f); /* use 5 decimal places */
printf("f = %-12.5f\n", f); /* left justify in field */
return 0;
}
|