你如何处理与NUL? [英] How do you deal with NUL?

查看:148
本文介绍了你如何处理与NUL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着时间的时候,我碰到的通信问题与其他程序员,当我们谈论NULL。现在NULL可能是



NULL指针

NUL字符

在某种数据库的一个空的数据元素。

From time to time, I run into communications issue with other programmers, when we talk about NULL. Now NULL could be

a NULL pointer
the NUL character
an empty data element in some sort of database.


NUL似乎是最令人困惑的。这是ASCII字符为0x00。

我倾向于使用'\\ 0'在我的code重新present它。在我的组一些开发商

倾向于preFER简单地使用0,并让编译器隐其转换为字符。


NUL seems to be the most confusing. It is the ASCII character 0x00.
I tend to use '\0' in my code to represent it. Some developers in my group
tend to prefer to simply use 0, and let the compiler implicitly cast it to a char.


你什么preFER用于NUL?为什么?


What do you prefer to use for NUL? and why?

推荐答案

我用'\\ 0'为NUL字符和 NULL 为指针,因为它是在两种情况下最清楚。

I use '\0' for the nul-character and NULL for pointers because it is clearest in both cases.

顺便说一句,这两个 0 '\\ 0' INT S IN C和任何一个将被转换为字符时,存储在字符变量。

BTW, both 0 and '\0' are ints in C and either one will be converted to char when stored in a char variable.

这篇关于你如何处理与NUL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆