Brain fade: pointer to char[][]

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My brain is full; I've had to stop thinking...

How do I define a pointer to an array of strings? Or even to an array of structs which are strings plus something else?

 
char * table[100][32];

I want to be able to point to the start of the table and address by row, e.g.

for (q=0; q<100; q++)
{
  if (strcmp(table[q],"hello"))
  ...
}

but I'd like to be able to replace 'table' with a pointer so I can use the same routine on different tables...

char * table_ptr = table;

doesn't work; I'm getting lost in levels of indirection... help!

Ta,

Neil

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

barnacle,

char * table[100][32];

I believe this creates an array of char pointers 100 X 32.

A

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Doh, where did that * come from? :mrgreen:

That means the analagous

struct Symbol {
	char symbol[32];
	};

struct Symbol SymTab[1000];

struct Symbol * TabPtr = SymTab;

seems to work, too...

Thanks

Neil