2维数组简单的理解 [英] 2 dimensional array simple understanding

查看:103
本文介绍了2维数组简单的理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的,我不明白为什么我做了一些事情的一些老code。
我有一个指针是 int_16t * Q ,1024整数。现在我想将它与复制:

I have some old code of mine which i dont understand why i did some thing . I have a pointer which is int_16t *q, of 1024 ints . now i am trying to copy it with :

       buffersRing[ringNum][0]=inNumberFrames;
       memcpy(buffersRing[ringNum]+1, q, inNumberFrames * sizeof *q); 

当在阵列的第一位置是一些int变量,和所有其他的地方后分别为Q

when first place in array is some int variable, and all other place after that are q.

但是,为什么我havnt做到这一点(和最新的区别):

But, why i havnt done that(and whats the difference ) :

    buffersRing[ringNum][0]=inNumberFrames;
    memcpy(buffersRing[ringNum][1], q, inNumberFrames * sizeof *q); 

时它试图把所有的Q整数到阵列摆在首位?或者是一样的吗?

Is it trying to put all q ints into the first place in array ? or is it the same?

推荐答案

没有

buffersRing[ringNum]+1 // refers to a pointer to an array element

是不一样的

buffersRing[ringNum][1] // refers to the actual array element

第一个是你想要的。

The first one is the one you want.

这篇关于2维数组简单的理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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