All pastes #496733 Raw Edit

hisham

public c v1 · immutable
·published 2007-05-19 12:46 UTC
rendered paste body
#include <stdio.h>#include <string.h>typedef struct _Typle Tuple;typedef struct _Attribute Attribute;struct _Tuple{   char *key;   int value;};struct _Attribute{   char *name;   struct _Tuple **tuples;};static struct _Tuple _first_tuple ={   "key1",   1};static struct _Tuple _second_tuple ={   "key2",   2};static struct _Tuple _third_tuple ={   "key3",   3};static struct _Tuple *tuples[] ={	&_first_tuple,	&_second_tuple,	&_third_tuple,	NULL};static const struct _Attribute attrib1 ={   "first attrib",   tuples};static struct _Tuple _first_tuple2 ={   "key1-2",   1};static struct _Tuple _second_tuple2 ={   "key2-2",   2};static struct _Tuple _third_tuple2 ={   "key3-2",   3};static struct _Tuple *tuples2[] ={	&_first_tuple2,	&_second_tuple2,	&_third_tuple2,	NULL};static const struct _Attribute attrib2 ={   "second attrib",   tuples2};static const struct _Attribute *attributes[] = {   &attrib1,   &attrib2,   NULL};int main(void){   int i;   struct _Attribute *attrib;      for (i = 0; attributes[i]; i++)     {	int j;	struct _Tuple *tuple;		attrib = attributes[i];	printf("%s\n", attrib->name);		for (j = 0; attrib->tuples[j]; j++)	  {	     tuple = attrib->tuples[j];	     printf("  %s\n", tuple->key);	  }     }         return 0;}