“int *a[5]"和“int *a[5]"有什么区别?和 int(*a)[5]"? [英] What's the difference between "int *a[5]" and int(*a)[5]"?
本文介绍了“int *a[5]"和“int *a[5]"有什么区别?和 int(*a)[5]"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它们在 C 和 C++ 上的工作方式会不同吗?
Would they work differently on C and C++?
推荐答案
int *a[5] -
这意味着a"是一个指针数组,即数组a"中的每个成员都是一个指针
整数类型;数组的每个成员都可以保存一个整数的地址.
int *a[5] -
It means that "a" is an array of pointers i.e. each member in the array "a" is a pointer
of type integer; Each member of the array can hold the address of an integer.
int (*a)[5] -
这里的a"是指向 5 个整数数组的指针,换句话说a"指向一个包含 5 个整数的数组.
int (*a)[5] -
Here "a" is a pointer to the array of 5 integers, in other words
"a" points to an array that holds 5 integers.
示例:
#include<stdio.h>
int main()
{
int b = 3;
int c = 4;
int *a[2] = {&b, &c}; // is same as ---int *a[] = {&b, &c}
printf("value pointed to by a[0] = %d, by a[1] = %d\n", *a[0], *a[1]);
return 0;
}
这篇关于“int *a[5]"和“int *a[5]"有什么区别?和 int(*a)[5]"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文