33,311
社区成员
发帖
与我相关
我的任务
分享
void main()
{
int( *ptr1[4] );
int * ptr2[4];
cout << typeid(ptr1).name() << endl
<< typeid(ptr2).name() << endl
<< boolalpha << bool(typeid(ptr1) == typeid(ptr2)) << endl;
}
/*
output:
int * [4]
int * [4]
true
*/
#include<iostream>
//#include<string>
//#include<vector>
//#include<fstream>
using namespace std;
void test(int(*[2]));
void test1(int* [2]);
int main()
{
int dem[2][2]={1,2,3,4};
int (*pt)[2]=dem;
int *ptr[2];
int num1=45;
int num2=50;
int num3=60;
int num4=70;
ptr[0]=&num1;
ptr[1]=&num2;
//int *pt1
test(ptr);
//test(pt);
test1(ptr);
return 0;
}
void test(int *arr[2])
{
cout<<**arr<<" "<<**(arr+1)<<endl;
}
void test1(int* array[2])
{
cout<<**array<<" "<<**(array+1)<<endl;
cout<<endl;
}
//实验证明:int(*[4])和int* [4]的一样的
#include<iostream>
using namespace std;
int main()
{
int arr[3][4];
int *p[4];
//p=&arr[0];
int (*p2)[4];
p2=&arr[0];
return 0;
}
#include<stdio.h>
typedef char (* typeL[4]);
void main()
{
char c='a';
char c1[4]={48,49,50,51};
char (*p[4]); //p为含有4个char*指针的数组 p在此为数组名,其为地址常量,不能作这左值
char (*p2)[4]; //p2为一个指针变量,sizeof(p2)=4 即p2可以指向一个有4个char的数组。 可以作为左值和右值
*(int*)(&p2)=(int)c1; //c1在此作为一个地址常量 绕来绕去的赋值法则
p2=&c1; //取地址&操作,返回的指向数组的指针,同样sizeof(c1)返回整个数组的字节数
char * pchar=c1; //当c1作为右值或是形参时,则仅仅是数组第一个元素的地址
const char kk='k';
p[0]=&c1[0];
p[1]=&c1[1];
p[2]=&c1[2];
p[3]=&c1[1];
}