Passing an array of pointers to a function. - C Pointer

C examples for Pointer:Array Pointer

Description

Passing an array of pointers to a function.

Demo Code

#include <stdio.h>

void print_strings(char *p[], int n);

int main( void )
{
   char *message[8] = { "test", "test test", "test test test", "aaaa", "aaaaaa", "bbbbbb,", "cccccc", "eeeeee" };

   print_strings(message, 8);/*from w ww .ja  va2s  . com*/
   return 0;
}

void print_strings(char *p[], int n)
{
   int count;

   for (count = 0; count < n; count++)
       printf("%s ", p[count]);
   printf("\n");
}

Result


Related Tutorials