ptr3.c

来自「linux下的C语言开发」· C语言 代码 · 共 29 行

C
29
字号
/*-*//******************************************************** * Program: Array initialization			* *							* * Purpose: Show how to initialize an array.		* *							* * Usage: Run the program and look at the results.	* *							* * Note: Same as the previous program but uses 		* *	pointer arithmetic instead of array indices.	* ********************************************************//*+*/#include <stdio.h>int array[] = {4, 5, 8, 9, 8, 1, 0, 1, 9, 3};int *array_ptr;int main(){    array_ptr = array;    while ((*array_ptr) != 0)        ++array_ptr;    printf("Number of elements before zero %d\n",                  array_ptr - array);    return (0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?