1、 KS X 2012 KSKSKSKS SKSKSKS KSKSKS SKSKS KSKS SKS KS C KS X 2012 : 2007 (2012 ) 2007 10 30 http:/www.kats.go.krKS X 2012:2007 : ( ) ( ) SJ ( ) : () ( ) Microsoft IBM KS X 2012:2007 : (http:/www.standard.go.kr) : :1992 12 17 :2007 10 30 :2012 12 28 : 2012-0797 : (JTC1/SC22) ( 02-509-7262) (http:/www.
2、kats.go.kr). 10 5 , . KS X 2012:2007 i 1 1 2 .1 3 .2 3.1 2 3.2 4 4 .9 4.1 9 4.2 .18 4.3 .19 4.4 27 4.5 .28 4.6 .34 4.7 36 4.8 (preprocessing directives) .38 5 (Library).43 5.1 .43 5.2 45 5.3 45 5.4 .51 5.5 54 5.6 59 5.7 .60 5.8 61 5.9 /62 5.10 80 5.11 88 5.12 96 A() C 100 A.1 .100 A.2 .108 A.3 .114
3、KS X 2012 : 2007 (2012 ) C Information technology C language in unix environment 1 C , C . a) C b) C c) C d) C e) C f) C g) 2 . a) LANG , , . LANG locale . b) LC-COLLATE c) LC-CTYPE d) LC-MONETARY e) LC-NUMERlC f) LC-TIME g) Locale . 1 . h) NLSPATH i) (empty string) j) , . , , , . . k) , l) m) n) ,
4、. o) KS X 2012:2007 2 . “ ” “ ” . p) . q) . . , . , . r) 2 s) . . t) (decimal-point character) . , setlocale . u) (string) . . v) w) x) . “” “ ” . y) (alignment) z) , , . . aa) ab) (local custom) , , ac) (localization) , , ad) ae) KS X 1001, ( ) af) . , “W” . 3 3.1 3.1.1 C . . #include . . , , . , .
5、 . a) ( ) KS X 2012:2007 3 . b) . , . c) ( ) . . , . . d) , . #include 1 4 . e) (escape sequence) . f) , . g) . . . h) . . . ( ) . . 3.1.2 2 . C . ( ) . . . a) (C ) . . . . b) , . main. . . int main (void)/*/ 2 ( , argc argv ) . int main (int argc, char *argv) /*/ main , . 1) argc . 2) argvargc . 3)
6、 argc 0 , argv0 argvargc-1 . . KS X 2012:2007 4 . , . 4) argc 0 , argv0 . argv00 . argc 1 argv1 argvargc-1 . 5) argc argv argv , . , , , . main main exit . main . c) , , . . (sequential point) , . . ( ). , . . , . . 1) , . 2) . 3) 5.9 . . 3.2 3.2.1 2 . . . 0 (null character) , . . KS X 2012:2007 5 2
7、6 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 26 a b c d e f g h i j k l m n o p q r s t u v w x y z 10 10 0 1 2 3 4 5 6 7 8 9 29 ! # % ? - 1 , , (form feed) . , . , , (carrige return), . ( , , , , ) . a) . , . . 1) 3.2 . 2) , (locale-specific). 3) (state-dependent) . 4) 0 . 5) 0 2 . . 1) ,
8、, . 2) , , . 3.2.2 fputc . (isprint ) , . . . . a() . . b() . KS X 2012:2007 6 . f( ) n() r() t( ) . . v( ) . . 3.2.3 ( , , ) , . ( ) . , . 3.2.4 a) 1 . 1) , , 15 2) 8 3) , , , 12 , , 4) 31 5) 32 6) 31 7) 6 8) 511 9) 127 10) 1024 11) 31 12) 31 13) 31 14) 509 15) 509 ( ) 16) 32767( ) 17) #include 8 1
9、8) switch 257 case ( switch ) 19) 127 20) 127 21) 15 b) (limits. h (float. h . 1) (limits.h CHAR-BIT MB-LEN-MAX . KS X 2012:2007 7 , () . 1.1) () CHAR_BIT 8 1.2) signed char SCHAR_MIN 127 1.3) signed char SCHAR_MAX 127 1.4) unsigned shar UCHAR_MAX 255 1.5) char CHAR_MIN 127, 0 1.6) char CHAR_MAX 127
10、, 255 1.7) MB_LEN_MAX 2 1.8) short int SHRT_MIN 32764 1.9) short int SHRT_MAX 32767 1.10) unsigned short int USHRT_MAX 65535 1.11) int INT_MIN 32767 1.12) int INT_MAX +32767 1.13) unsigned int UINIT_MAX 65535 1.14) long int LONG_MIN 2147483647 1.15) long int LONG_MAX 2147483647 1.16) unsigned long i
11、nt ULONG_MAX 4294967295 2) . KS X 2012:2007 8 s (1) b , ( 1) e (e min e max ) p ( b ) f kb x(f 1 0, x0) . xsb e p 1 k k f b K , e min e e max FLT-RADIX #if . . FLT-RADIX FLT-ROUNDS 3 . FLT-ROUNDS . FLT-ROUNDS . 1 0 0 1 2 3 FLT-RADIX . , () . 2.1) FLT_RADIX 2 2.2) FLT-RADIX FLT_MANT_DIG DBL_MANT_DIG
12、LDBL_MANT_DIG 2.3) q q b p , q . (p1)*log 10 b FLT_DIG 6 DBL_DIG 10 LDBL_DIG 10 2.4) FLT-RADIX 1 (e min ). FLT_MIN_EXP DBL_MIN_EXP LDBL_MIN_EXP 2.5) 10 . 1og 10 b e (e e min 1) FL T_MIN_10_EXP 37 DBL_MIN_10_EXP 37 LDBL_MIN_10_EXP 37 2.6) FLT-RADIX 1 (e max ). FLT_MAX_EXP 1, b 10 0, KS X 2012:2007 9
13、DBL_MAX_EXP LDBL_MAX_EXP 2.7) 10 . log 10 (1b p )b e (e e max ) FLT_MAX_10_EXP 37 DBT_MAX_10_EXP 37 LDBL_MAX_10_EXP 37 () . 2.8) (1b -p )b e (e e max ) FL T_MAX 1E 37 DBL_MAX 1E 37 LDBL_MAX 1E 37 () . 2.9) 1 1 (b 1P ) FLT_EPSILON 1E5 DBL_EPSILON 1E9 LDBL_EPSILON 1E 9 2.10) (:b :e min 1) FL T_MIN 1E
14、37 DBL_MIN 1E 37 LDBL_MIN 1E 37 4 4.1 a) token: keyword identifier constant string-literal operator punctuator preprocessing-token: header-name identifier pp-number character-constant string-literal operator punctuator KS X 2012:2007 10 b) , . (keyword), (identifier), (constant), (string literal), (
15、operator), (punctuator) . (preprocessing token) . (header name), , (preprocessing number), (character constant), , , (non-white-space) . “ ” . (white-space) , (space), / , , . . , . 4.1.1 a) keyword: auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while b) ( ). 4.1.2 a) identifier: nondigit identifier nondigit identifier digit nondigit: - a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P