int x[] 和 int *x 之间有区别吗? [英] Is there a differene between int x[] and int *x?

查看:128
本文介绍了int x[] 和 int *x 之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个函数来搜索一个数字,如下所示..

I'm studying a function to search for a number where that goes as the following..

int sequential_search (int num, int a[], int size);

在 main 中, a 定义如下.

And in main , a is defined as the following.

int *a;
a = new int[size];

所以我想知道它是否是同一件事..提前致谢

So I was wondering if its the same thing.. Thanks in advance

推荐答案

当用作函数参数时没有区别.

When used as function parameter then there is no difference.

int sequential_search (int num, int a[], int size);  

相当于

int sequential_search (int num, int *a, int size);  

否则两者都不同:int x[]x 声明为 int 的数组而 int *xx 声明为指向 int 的指针.

Otherwise both are different: int x[] declare x as an array of ints while int *x declare x as a pointer to int.

这篇关于int x[] 和 int *x 之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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