当前位置:网站首页>Start the remedial work. Print the contents of the array using the pointer

Start the remedial work. Print the contents of the array using the pointer

2022-07-05 02:06:00 Xiao Sun's code sharing

Write a function to print arr Contents of array , Do not use array subscripts , Use the pointer .

arr Is an integer one-dimensional array .

#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int arr[] = {1,2,3,4,5,6,7,8,9};
	int* p = arr;// Defining pointer variables 
	int len = sizeof(arr) / sizeof(arr[0]);// Calculate the length of the array 
	for (int i = 0; i <len; i++)
	{
		printf("%d\n", *p);
		++p;
	}
}

原网站

版权声明
本文为[Xiao Sun's code sharing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140950517948.html