空在计算机编程中是什么意思?

In computer programming, null is both a value and a pointer. Null is a built-in constant that has a value of zero. It is the same as the character 0 used to terminate strings in C. Null can also be the value of a pointer, which is the same as zero unless the CPU supports a special bit pattern for a null pointer.

在计算机编程中,null既是值又是指针。 Null是一个内置常数,值为零。 它与用于终止C中的字符串的字符0相同。Null也可以是指针的值,该值等于零,除非CPU支持null指针的特殊位模式。

什么是空值? ( What Is a Null Value? )

In a database, zero is a value. The value null means that no value exists. When used as a value, null is not a memory location. Only pointers hold memory locations. Without a null character, a string would not correctly terminate, which would cause problems.

数据库中 ,零是一个值。 值null表示不存在任何值。 当用作值时,null不是存储位置。 只有指针保存内存位置。 没有空字符,字符串将无法正确终止,这将导致问题。

什么是空指针? ( What Is a Null Pointer? )

The C and C++ programming, a pointer is a variable that holds a memory location. The null pointer is a pointer that intentionally points to nothing. If you don't have an address to assign to a pointer, you can use null. The null value avoids memory leaks and crashes in applications that contain pointers. An example of a null pointer in C is:

在C和C ++编程中,指针是保存内存位置的变量。 空指针是故意不指向任何内容的指针。 如果没有要分配给指针的地址,则可以使用null。 null值可避免内存泄漏和包含指针的应用程序崩溃。 C中的空指针的示例是:


in


<


  int *ptr 


  printf("The value of ptr is %u


  r


<

Note: In C, the null macro may have the type void* but this is not allowed in C++.

注意:在C语言中,null宏的类型可能为void *,但这在C ++中是不允许的。

C#中为Null ( Null in C# )

In C#, null means "no object." Information about null and its usages in C# include:

在C#中,null表示“无对象”。 有关null及其在C#中的用法的信息包括:

  • You cannot use 0 instead of null in your programs even though null is represented by the value 0.

    即使用值0表示null,也不能在程序中使用0而不是null。
  • You can use null with any reference type including arrays, strings, and custom types.

    您可以对任何引用类型(包括数组,字符串和自定义类型)使用null。
  • In C#, null is not the same as the constant zero. 

    在C#中,null与常数零不同。

翻译自: https://www.thoughtco.com/definition-of-null-958118

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值