C Programming

⌘K
  1. Home
  2. Docs
  3. C Programming
  4. Pointers
  5. Array of Pointers

Array of Pointers

An array of pointers is an array where each element is a pointer.

  • Useful for storing addresses of strings or arrays.
  • You can declare an array of pointers and assign pointers to strings or other data.
  • This is commonly used for storing multiple strings.

Example:

#include <stdio.h>

int main() {
    // Array of pointers to strings
    char *colors[] = {"Red", "Green", "Blue", "Yellow"};

    for(int i = 0; i < 4; i++) {
        printf("Color %d: %s\n", i+1, colors[i]);
    }

    return 0;
}

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *