Accessing array elements using pointers in C || Pointers || C Programming
In this, we are going to access elements of an array by using Pointers in C Programming Language.

 

#include <stdio.h>
int main()
{
    char x[] = {'A','B','C','D','E'};
    char *ptr = x; // points to the 0th element of array

    //accessing elements of array using pointers
    for (int i = 0; i < 5; i++)
    {
        printf("%c ", *(ptr + i)); // add i to the 0th element
    }
    return 0;
}

//..........Coded by Ananya Maurya

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post