博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c 语言 整数布尔值_C中的布尔值
阅读量:2514 次
发布时间:2019-05-11

本文共 1351 字,大约阅读时间需要 4 分钟。

c 语言 整数布尔值

C originally did not have native support for boolean values.

C最初不支持布尔值。

C99, the version of released in 19992000, introduced a boolean type.

C99是1999年 / 2000年发布的版本,引入了布尔类型。

To use it, however, you need to import a header file, so I’m not sure we can technically call it “native”. Anyway, we do have a bool type.

但是,要使用它,您需要导入头文件,因此我不确定我们在技术上可以称其为“本机”。 无论如何,我们确实有bool类型。

You can use it like this:

您可以像这样使用它:

#include 
#include
int main(void) { bool isDone = true; if (isDone) { printf("done\n"); } isDone = false; if (!isDone) { printf("not done\n"); }}

If you’re programming the Arduino, you can use bool without including stdbool because bool is a valid and built-in C++ data type, and the is C++.

如果您正在对Arduino进行编程,则可以在不包含stdbool情况下使用bool ,因为bool是有效的内置C ++数据类型,而是C ++。

In plain C, remember to #include <stdbool.h> otherwise you’ll get a bunch of errors at declaration and any time you use the bool variable:

在普通C语言中,请记住#include <stdbool.h>否则在声明时以及每次使用bool变量时都会出现很多错误:

➜  ~ gcc hello.c -o hello; ./hellohello.c:4:3: error: use of undeclared identifier      'bool'  bool isDone = true;  ^hello.c:5:7: error: use of undeclared identifier      'isDone'  if (isDone) {      ^hello.c:8:8: error: use of undeclared identifier      'isDone'  if (!isDone) {       ^3 errors generated.

翻译自:

c 语言 整数布尔值

转载地址:http://mwqgb.baihongyu.com/

你可能感兴趣的文章
新建 WinCE7.0 下的 Silverlight 工程
查看>>
腾讯的张小龙是一个怎样的人?
查看>>
jxl写入excel实现数据导出功能
查看>>
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>
btn按钮之间事件相互调用
查看>>
Entity Framework 4.3.1 级联删除
查看>>
codevs 1163:访问艺术馆
查看>>
冲刺Noip2017模拟赛3 解题报告——五十岚芒果酱
查看>>
并查集
查看>>
sessionStorage
查看>>
代码示例_进程
查看>>
Java中关键词之this,super的使用
查看>>
人工智能暑期课程实践项目——智能家居控制(一)
查看>>
前端数据可视化插件(二)图谱
查看>>
kafka web端管理工具 kafka-manager【转发】
查看>>
获取控制台窗口句柄GetConsoleWindow
查看>>
Linux下Qt+CUDA调试并运行
查看>>