The checking for NULL trick only works for NULL terminated strings. For a numeric array you'll have to pass in the size too.

void printArray(int *ptr, size_t length);            
{         
    //for statement to print values using array             
    size_t i = 0;
    for( ; i < length; ++i )      
    printf("%d", ptr[i]);        
}   

 void printString(const char *ptr);            
{         
    //for statement to print values using array             
    for( ; *ptr!='\0'; ++ptr)        
    printf("%c", *ptr);        
}         

int main()    
{    
    int array[6] = {2,4,6,8,10};     
    const char* str = "Hello World!";
    printArray(array, 6);    
    printString(str);
    return 0;     
}
Answer from Praetorian on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_pointers_arrays.php
C Pointers and Arrays
You can also use pointers to access arrays. ... int myNumbers[4] = {25, 50, 75, 100}; int i; for (i = 0; i < 4; i++) { printf("%d\n", myNumbers[i]); }
๐ŸŒ
Codeforwin
codeforwin.org โ€บ home โ€บ c program to input and print array elements using pointers
C program to input and print array elements using pointers - Codeforwin
July 20, 2025 - You can either use (ptr + 1) or ptr++ to point to arr[1]. /** * C program to input and print array elements using pointers */ #include <stdio.h> #define MAX_SIZE 100 // Maximum array size int main() { int arr[MAX_SIZE]; int N, i; int * ptr = ...
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ c-program-to-read-and-print-array-elements-using-a-pointer
C Program to Read and Print Array Elements using a Pointer
December 19, 2024 - #include <stdio.h> int main() { ... { scanf("%d", parr + i); } printf("Printing Array Elements using Pointer\n"); for (i = 0; i < Size; i++) { printf("%d ", *(parr + i)); } printf("\n"); } In this c example, the insertArrayItem ...
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ examples โ€บ access-array-pointer
C Program to Access Array Elements Using Pointer
#include <stdio.h> int main() { int data[5]; printf("Enter elements: "); for (int i = 0; i < 5; ++i) scanf("%d", data + i); printf("You entered: \n"); for (int i = 0; i < 5; ++i) printf("%d\n", *(data + i)); return 0; } ... In this program, the elements are stored in the integer array data[]. ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ array-of-pointers-in-c
Array of Pointers in C - GeeksforGeeks
July 23, 2025 - After that, we can assign a string of any length to these pointers. ... Note: Here, each string will take different amount of space so offset will not be the same and does not follow any particular order. This method of storing strings has the advantage of the traditional array of strings. Consider the following two examples: ... // C Program to print Array of strings without array of pointers #include <stdio.h> int main() { char str[3][10] = { "Geek", "Geeks", "Geekfor" }; printf("String array Elements are:\n"); for (int i = 0; i < 3; i++) { printf("%s\n", str[i]); } return 0; }
๐ŸŒ
Programming9
programming9.com โ€บ programs โ€บ c-programs โ€บ 169-c-program-to-print-elements-of-array-using-pointers
C Program to Print Elements of Array Using Pointers
#include<stdio.h> int main() { int a[5]= {5,4,6,8,9}; int *p=&a[0]; int i; for(i=0; i<5; i++) printf("\nArray[%d] is %d ",i,*(p+i)); for(i=0; i<5; i++) printf("\n %d at %u ",*(p+i),(p+i)); return 0; } Array[0] is 5 Array[1] is 4 Array[2] is 6 Array[3] is 8 Array[4] is 9 5 at 2686708 4 at 2686712 ...
Find elsewhere
๐ŸŒ
Technosap
technosap.com โ€บ home โ€บ c programming โ€บ examples โ€บ c program to print elements of array using pointers
C Program to Print Elements of Array using Pointers - Technosap
February 11, 2019 - ... Program to print the elements of array using pointers* #include<stdio.h> main() { int a[5]={5,4,6,8,9}; int *p=&a[0]; int i; clrscr(); for(i=0;i<5;i++) printf("%d ",*(p+i)); getch(); }
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ cprogramming โ€บ c_array_of_pointers.htm
Array of Pointers in C
The following example demonstrates how you can create and use an array of pointers. Here, we are declaring three integer variables and to access and use them, we are creating an array of pointers. With the help of an array of pointers, we are printing the values of the variables.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_pointers_arithmetic.php
C Pointer Arithmetic
So if a pointer points to one element, adding 1 moves it to the next one: int myNumbers[4] = {25, 50, 75, 100}; int *p = myNumbers; // points to myNumbers[0] printf("%d\n", *p); // 25 printf("%d\n", *(p + 1)); // 50 printf("%d\n", *(p + 2)); ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ c-program-to-print-array-of-pointers-to-strings-and-their-address
C program to print array of pointers to strings and their address
March 19, 2021 - #include<stdio.h> #include<string.h> void main(){ //Declaring string and pointers, for loop variable// int i; char *a[5]={"One","Two","Three","Four","Five"}; //Printing values within each string location using for loop// printf("The values in every string location are : "); for(i=0;i<5;i++){ printf("%s ",a[i]); } //Printing addresses within each string location using for loop// printf("The address locations of every string values are : "); for(i=0;i<5;i++){ printf("%d ",a[i]); } } When the above program is executed, it produces the following result โˆ’ ยท The values in every string location are: One Two Three Four Five The address locations of every string values are: 4210688 4210692 4210696 4210702 4210707 ยท Letโ€™s consider another example. Stated below is a C program demonstrating the concept of array of pointers to string โˆ’
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 72387178 โ€บ how-to-print-array-elements-using-pointer-in-c
how to print array elements using pointer in c? - Stack Overflow
May 26, 2022 - Reset ptr variable to &arr[0] after first and before second for loop. ... For the first element of the array you don't need to assign with & operator you can directly assign the pointer ` int *ptr = arr;`.
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 2752595 โ€บ how-to-print-value-from-array-using-pointer-to-array
How to print value from array using pointer to array | Sololearn: Learn to code for FREE!
No, we can't By doing int (*ptr)[2] = &arr; We are declaring a single pointer which is meant to point at a data type of " int (*)[2] " which is an integer array of size 2 and making it point to the array "arr" which has to be of size 2 otherwise ...
๐ŸŒ
w3resource
w3resource.com โ€บ c-programming-exercises โ€บ pointer โ€บ index.php
C programming exercises: Pointer - w3resource
Write a program in C to compute the sum of all elements in an array using pointers. Test Data : Input the number of elements to store in the array (max 10) : 5 Input 5 number of elements in the array : element - 1 : 2 element - 2 : 3 element - 3 : 4 element - 4 : 5 element - 5 : 6 ... Write a program in C to print the elements of an array in reverse order.
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2014 โ€บ 01 โ€บ c-pointer-to-array-example
Pointer and Array in C programming with example
I recommend you to refer Array and Pointer tutorials before going though this guide so that it would be easy for you to understand the concept explained here. #include <stdio.h> int main( ) { int val[7] = { 11, 22, 33, 44, 55, 66, 77 } ; /* for loop to print value and address of each element of array*/ for ( int i = 0 ; i < 7 ; i++ ) { /* The correct way of displaying the address would be using %p format * specifier like this: * printf("val[%d]: value is %d and address is %p\n", i, val[i], &val[i]); * Just to demonstrate that the array elements are stored in contiguous * locations, I m displaying the addresses in integer */ printf("val[%d]: value is %d and address is %d\n", i, val[i], &val[i]); } return 0; }
๐ŸŒ
W3Resource
w3resource.com โ€บ c-programming โ€บ c-arrays-and-pointers.php
C - Arrays and Pointers
3 weeks ago - Print array elements using the array notation and by dereferencing the array pointers: nums[0] = 0 ptr + 0 = 0 nums[1] = 5 ptr + 1 = 5 nums[2] = 87 ptr + 2 = 87 nums[3] = 32 ptr + 3 = 32 nums[4] = 4 ptr + 4 = 4 nums[5] = 5 ptr + 5 = 5
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to print array elements using pointer in c - YouTube
We can dereference a pointer using a subscript [] operator to print out the array.
Published ย  March 16, 2024
๐ŸŒ
w3resource
w3resource.com โ€บ c-programming-exercises โ€บ array โ€บ c-array-exercise-1.php
C Program: Read and Print elements of an array - w3resource
September 27, 2025 - The above program first prompts ... elements of the array using another for loop that runs from i=0 to i<n and uses the printf() function to print each element of the array....