这是什么意思是"由零"?终止 [英] What does it mean to be "terminated by a zero"?

查看:167
本文介绍了这是什么意思是"由零"?终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进入C / C ++和大量的术语如雨后春笋般冒出生疏了。其中之一是由一零终止的变量或指针。这是什么意思在内存空间由一个零终止?

I am getting into C/C++ and a lot of terms are popping up unfamiliar to me. One of them is a variable or pointer that is terminated by a zero. What does it mean for a space in memory to be terminated by a zero?

推荐答案

参加ASCII字符串你好。在内存最简单的重新presentation是两个字节:

Take the string Hi in ASCII. Its simplest representation in memory is two bytes:

0x48
0x69

但是,这是否一块内存结束?除非你也$ ppared通过串绕中的字节数p $,你不知道 - 内存条没有本质上的长度

But where does that piece of memory end? Unless you're also prepared to pass around the number of bytes in the string, you don't know - pieces of memory don't intrinsically have a length.

所以C有一个标准的字符串以零字节,也称为 NUL 字符结尾:

So C has a standard that strings end with a zero byte, also known as a NUL character:

0x48
0x69
0x00

该字符串现在是明确长两个字符,因为有两个字符前 NUL

这篇关于这是什么意思是"由零"?终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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