typedef-ing an array

Peter Clark pclark at SRC.Honeywell.COM
Fri Jun 29 09:41:11 AEST 1990


I wrote:

>Is there anyway to typedef an array (of a specific length)? Obviously, the
>above declaration doesn't do it, or I wouldn't be asking. If the typedef
>mechanism isn't sufficient (I don't think it is), how can this be done?

which wasn't specific enough. What I meant was, why doesn't this work:

-----------------------------------------

#include <stdio.h>

typedef char foo[29];

/* a string with 28 chars, add one for the NULL byte */
foo bar = "Hello World, this is my test";

void
  main()
{
  bar = "Silly old me";
  printf("%s\n",bar);
}
--------------------------------------------------

The initializer works fine, but the assignment inside main() doesn't.

	Pete Clark



More information about the Comp.lang.c mailing list