C Online Compiler
Example: Basic Pointer to Array Element in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Basic Pointer to Array Element #include <stdio.h> int main() { // Step 1: Declare and initialize an array int numbers[] = {10, 20, 30, 40, 50}; // Step 2: Declare a pointer and point it to the first element of the array int *ptr = numbers; // 'numbers' itself decays to a pointer to its first element // Step 3: Access the first element using the pointer printf("Value of the first element (using pointer): %d\n", *ptr); return 0; }
Output
Clear
ADVERTISEMENTS