Re: Segmentation fault!
- From: "Rod Pemberton" <do_not_have@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 11 Feb 2006 17:25:17 -0500
"Chris Torek" <nospam@xxxxxxxxx> wrote in message
news:dslkac02uq3@xxxxxxxxxxxxxxxxxxxx
Rod Pemberton wrote:
Wouldn't kids be better defined like so:
struct _node_t *(kids[]);
This is a C99 feature: a structure that ends with a member of type
"array of T" (for some valid data type T), with no size, creates
a struct type with a "flexible array member". While C99-conformant
compilers are becoming more common, in my opinion they are not yet
common enough to recommend regular use of C99 features. Still,
this is a reasonable thing to do if you have C99 compilers. This
gives:
Just an FYI (for others, since Chris is probably familiar), this technique
existed prior to C99. It was called the C90 'struct hack' and works with
almost all C compilers. When standardized in C99, it became known as
variable length arrays.
If you've never heard of the C90 'struct hack', read #28 here:
http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.html
Rod Pemberton
.
- Follow-Ups:
- Re: Segmentation fault!
- From: Keith Thompson
- Re: Segmentation fault!
- References:
- Segmentation fault!
- From: Paminu
- Re: Segmentation fault!
- From: Vladimir S. Oka
- Re: Segmentation fault!
- From: Rod Pemberton
- Re: Segmentation fault!
- From: Chris Torek
- Segmentation fault!
- Prev by Date: Re: Random Numbers
- Next by Date: getchar() reading alphanumeric data
- Previous by thread: Re: Segmentation fault!
- Next by thread: Re: Segmentation fault!
- Index(es):
Relevant Pages
|