Newsgroups: comp.lang.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!munnari.oz.au!cs.mu.OZ.AU!mullauna!gwing
From: gwing@mullauna.cs.mu.OZ.AU (Geoff C Wing)
Subject: Initializing complex structured arrays: HOW?
Message-ID: <gwing.678270801@mullauna>
Summary: Can a complex structured array be initialized easily?
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
Date: Sun, 30 Jun 1991 08:33:21 GMT
Lines: 25


How can one initialize an array of structures if the structure is not simple,
in this case containing a union?

/* here's the standard version: */
struct standard_struct
{
	int integer1;
};
struct standard_struct standard[] = { 10, 20, 30, 40 };


/* and here's the desired version */
struct test_struct
{
	union {
		int integer2;
		char letter2;
	} hmmm;
};
struct test_struct test[] = { 10, 'a', 30, 40 };
  |        Geoff C Wing       |         \   _  _ _ _  __
  |gwing@mullauna.cs.mu.oz.au |      //  \  |\/|  |  / __  /\
  |gwing@munmurra.cs.mu.oz.au |    \X/ /\ \ |  | _|_ \__| //\\
  |static@phoenix.pub.uu.oz.au| 
