本文介绍了什么是添加单在C做一个字符数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待通过一些code为学习的目的。我通过code的这部分工作。

I'm looking through some code for learning purposes. I'm working through this portion of code.

// e.g. const unsigned char data={0x1,0x7C ... }
unsigned char buf[40];
memset(buf,0,40);
buf[0] = 0x52;
memcpy(buf+1, data, length); // What does buf+1 do in this situation?

在最后一行,其中的memcpy叫什么buf绝对不+ 1吗? buf是一个字符数组,那么是什么+1办呢?

On the last line where memcpy is called what does buf+1 do? buf is a character array, so what does +1 do to it?

推荐答案

在C,每一个数组名是一个指针,所以这里的buf也意味着指针,指向的buf [0]。那么BUF + 1是指 BUF [1]的地址。

In C, every array name is a pointer, so buf here also means the pointer which point to buf[0].Then "buf+1" means "buf[1]"'s address.

这篇关于什么是添加单在C做一个字符数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 13:46