i want to create array of pointer. "aa" "ab" "ac"

i tried many thing but it still give me error.

char *table[3] = "aa", "ab", "ac";

or

char *table[3];
*table[0] = "aa";
*table[1] = "ab";
*table[2] = "ac";

try something like this:

  char *array[3];
  char x = 'a', y = 'b', z = 'c';

  array[0] = &x;
  array[1] = &y;
  array[2] = &z;

  for (int i=0; i< 3; i++) 
      printf( "%d = %c\n", i, *(array[i]) );

hm.. dont work

got it to work with windows using cygwin and linux gcc...
is there a specific error or output that happens when you compile or run the code?

i want to create array of pointer. "aa" "ab" "ac"

You've forgotten brackets .. {}, i.e.

const char *table[3] = {"aa", "ab", "ac"};

oh right, thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.