Hi
how is the typedef for monthTable working while the statement at line 6 not working?

#include <stdio.h>

typedef const char * monthTable[3];

// uncommenting the following generates compile error
//int[5] A;

int main()
{
	monthTable t1,t2={"Jan","Feb","Mar"};
	int i=0;
	for(i=0;i<3;i++)
	{
		printf("%s\n",t2[i]);
	}
	return 1;
}

>how is the typedef for monthTable working while the statement at line 6 not working?
The typedef is syntactically and semantically correct, while line 6 isn't valid C. Do you know how to declare an array in C? It's pretty easy given your code, just take the typedef and remove the typedef keyword. That turns the line into the declaration of an array called monthTable. Now compare that with line 6 and look for differences.

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.