Question: Differentiate arrays and pointers with an example .explain about arrays of pointers?

by Jaya
April 27, 2021

Dr Vijender April 28, 2021
This program explains the difference.
#include <stdio.h>
void printElement(char* q, int index){
   printf("Element at index(%d) is: %c\n", index, *(q+index));
int main() {
   char arr[] = {'A', 'B', 'C'};
   char* p = arr;
   printf("Size of arr[]: %d\n", sizeof(arr));
   printf("Size of p: %d\n", sizeof(p));
   printf("First element using arr is: %c\n", arr[0]);
   printf("First element using p is: %c\n", *p);
   printf("Second element using arr is: %c\n", arr[1]);
   printf("Second element using p is: %c\n", *(p+1));
   printElement(p, 2);
   return 0;