
- C 標準庫
- C 庫 - 首頁
- C 庫 - <assert.h>
- C 庫 - <complex.h>
- C 庫 - <ctype.h>
- C 庫 - <errno.h>
- C 庫 - <fenv.h>
- C 庫 - <float.h>
- C 庫 - <inttypes.h>
- C 庫 - <iso646.h>
- C 庫 - <limits.h>
- C 庫 - <locale.h>
- C 庫 - <math.h>
- C 庫 - <setjmp.h>
- C 庫 - <signal.h>
- C 庫 - <stdalign.h>
- C 庫 - <stdarg.h>
- C 庫 - <stdbool.h>
- C 庫 - <stddef.h>
- C 庫 - <stdio.h>
- C 庫 - <stdlib.h>
- C 庫 - <string.h>
- C 庫 - <tgmath.h>
- C 庫 - <time.h>
- C 庫 - <wctype.h>
- C 標準庫資源
- C 庫 - 快速指南
- C 庫 - 有用資源
- C 庫 - 討論
- C 程式設計資源
- C 程式設計 - 教程
- C - 有用資源
C 庫 - <iso646_h.h>
C 庫標頭檔案 <iso646_h.htm> 允許使用替代運算子,例如 and、xor、not 等,它們返回特定值。例如,在布林表示式中使用 "and" 代替 && 可以使程式碼更易讀。
有十一個宏派生自 iso646.h 標頭檔案:
宏 | 標記 |
---|---|
and | && |
and_eq | &= |
bitand | & |
bitor | | |
compl | ˜ |
not | ! |
not_eq | != |
or | || |
or_eq | |= |
xor | ^ |
xor_eq | ^= |
示例
以下是 C 庫標頭檔案 <iso646_h.htm> 的演示,使用替代運算子 ('and') 對兩個數字進行運算。
#include <stdio.h> #include <iso646.h> int main() { int a = 5; int b = 3; // Using the alternative 'and' operator int sum = a and b; printf("Sum of %d and %d = %d\n", a, b, sum); return 0; }
輸出
以上程式碼產生以下結果:
Sum of 5 and 3 = 1
示例
我們建立了一個使用替代運算子 (xor) 交換兩個數字的程式。
#include <stdio.h> #include <iso646.h> int main() { int x = 5; int y = 3; // Using the alternative 'xor' operator x = x xor y; y = x xor y; x = x xor y; printf("After swapping: x = %d, y = %d\n", x, y); return 0; }
輸出
執行上述程式碼後,我們得到以下結果:
After swapping: x = 3, y = 5
示例
下面的程式使用替代運算子計算兩個值的邏輯“and”。
#include <stdio.h> #include <iso646.h> int main() { int bool1 = 1; int bool2 = 0; int result = bool1 and bool2; printf("Logical AND of %d and %d = %d\n", bool1, bool2, result); return 0; }
輸出
執行程式碼後,我們得到以下結果:
Logical AND of 1 and 0 = 0
廣告