Pointers (2)-Use typedef to facilitate array pointers

typedef named array pointer

typedef: alias the type.
Use typedef to better understand and use array pointers

Often used in array pointers, structures...
#include<stdio.h>

//给基本类型取别名
typedef int IntType;
//给数组类型取别名
typedef int ArrType[5];
//给数组指针类型取别名
typedef int(*PArrType)[5];

int main() {
    
    

	IntType num = 999;
	printf("%d\n",num);

	int arr[5] = {
    
     1,2,3,4,5 };
	ArrType arr0 = {
    
     1,2,3,4,5 };

	int(*p)[5] = &arr;
	PArrType parr = &arr;
	PArrType parr0 = &arr0;

	return 0;
}

Guess you like

Origin blog.csdn.net/zhuiyizhifengfu/article/details/113855316