라벨이 C인 게시물 표시

C 언어: uname 함수

C언어: 시스템 정보 /// 헤더파일 #include <sys/utsname.h> /// 함수원형 int uname(struct utsname * name); /// 인자 struct utsname * name: 시스템 정보와 관련있는 utsname 구조체 /// 반환값 성공시 반환값(return value): 0 오류시 반환값(return value): -1 /// 참고파일 헤더파일: utsname.h(연결) 소스파일: uname.c(연결) reference https://man7.org/linux/man-pages/man2/olduname.2.html /// 예제 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 32 #include   < stdio.h > #include   < sys / utsname.h >   int  main( void ) {      struct  utsname system_info;       puts( "------ struct utsname ------" );     puts( "struct utsname {" );     puts( "    char sysname[];" );     puts( "    char nodename[];" );     puts( "    char release[];" );     puts( "    char version[];" );     puts( "    char machine[];" );     puts( "#ifdef _GNU_SOURCE" );       puts( "    char domainname[];" );        puts( "#

C 언어: 비트 연산(bitwise operation)_000029

C언어: 매크로사용 000001 /// 연산 INTEGER(32bit) = SHORT(16bit) + SHORT(16bit) /// 예제 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 #include   < stdio.h > #include   < stdlib.h > #include   < time.h >   #define  SETHIGHWORD(UINT, SINT)  ((UINT  &   0xFFFF )  |  (SINT  < <   16 )) #define  SETLOWWORD(UINT, SINT)   ((UINT  &   0xFFFF0000 )  |  SINT) #define  SETINTEGER(LW, HW)       (LW  |  (HW  < <   16 )) #define  GETHIGHWORD(UINT)        (UINT  > >   16 ) #define  GETLOWWORD(UINT)         (UINT  &   0xFFFF ) #define  GETINTEGER(LW, HW)       (LW  |  (HW  < <   16 ))   void  to_binary( unsigned   int  value);   int  main( void ) {      unsigned   int  integer;           srand(time( NULL ));           integer  =  ( unsigned   int )rand();       puts( "integ

C 언어: 비트 연산(bitwise operation)_000021

C언어: x * y /// 연산 x * y /// 예제 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 #include   < stdio.h > #include   < stdlib.h > #include   < time.h >   void  show_binary( int  value);   // decimal to bianry   int  sign_switch( int  x);        // sign switch int  adder( int  x,  int  y);       // adder int  multiplier( int  x,  int  y);  // simple multiplier   //--------------------- core gate ----------------------------------------------- extern   inline   int  not_gate( int  x)          {  return  (~x);  }        // not gate extern   inline   int  or_g

C 언어: 비트 연산(bitwise operation)_000030

C언어: 매크로사용 000002 /// 연산 변별 /// 예제 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 #include   < stdio.h >                 // bitwise            binary     octal     decimal  hex #define  A_BASIC  1                //= 000000001  00000001  1        0x00000001 #define  A_TYPE1 (A_BASIC  < <   1 )  //= 000000010  00000002  2        0x00000002 #define  A_TYPE2 (A_BASIC  < <   2 )  //= 000000100  00000004  4        0x00000004 //   .     .           .              //   .     .           . //   .     .           .   unsigned   int  set_A( unsigned   int  a); void  characteristics_of_A( unsigned   int  a);   int  main( void ) {      unsigned   int  a;           puts( "characteristics of A" );     puts( "--------------------" );     puts( "A_BASIC                    : 000000

C 언어: 비트 연산(bitwise operation)_000028

C언어: x / y /// 연산 x / y /// 예제 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 #include   < stdio.h >   int  sign_switch( int  x);        // sign change int  subtractor( int  x,  int  y);  // subtractor int  adder( int  x,  int  y);       // adder int  divider( int  x,  int  y);     // divider   // minimize usage of (/ → * → - → +) operator and floating-point // core gate -------------------------------------------------------------------- extern   inline   int  not_gate( int  x)          {  return  (~x);  }        // not gate extern   inline   int  or_gate( int  x,  int  y)    {  return  (x  |  y); }      // or gate extern   inline   int  and_gate( int  x,