stdbool.h

    • bool:定义为_Bool
    • true:定义为1。
    • false:定义为0。
    • __bool_true_false_are_defined:定义为1。
    1. #include <stdio.h>
    2. #include <stdbool.h>
    3. unsigned long div;
    4. bool isPrime = true;
    5. num = 64457;
    6. for (div = 2; (div * div) <= num; div++) {
    7. if (num % div == 0) isPrime = false;
    8. if (isPrime) {
    9. printf("%lu is prime.\n", num);
    10. } else {
    11. printf("%lu is not prime.\n", num);
    12. }
    13. return 0;