Re: Structures or Array Notation for many possible strings of finite length?
- From: Barry Schwarz <schwarzb@xxxxxxxxx>
- Date: Sat, 28 Oct 2006 16:17:14 -0700
On Sat, 28 Oct 2006 18:34:21 -0400, nospam <nospam@xxxxxxxxxx> wrote:
I have an application that processes 30 kinds of strings of that fit
in an array.
By processing, I mean
-check the value of certain characters or substrings to be
within contant bounds or a member of a list
-check the value of certain characters or substrings to be
within bounds defined by other characters or substrings
-call a series of functions based on value of certain
substrings.
Each kind of string has a different length, but it fits within an
array of 128 char's
Would you do the processing with array notation (using #defines for
the array indices) in order to write the clearest code , or would you
setup a union of 30 structs (one struct for each kind of sentence) to
write clearest code?
Which do you find easier to code and read later?
union{
struct {char c1[L1]}s1;
...
struct {char c30[L30]}s30;
}u
...
if (u.s19.c19[5] == 'x'){...}
or
#define POS19 5
char c[128];
...
if (c[POS19] == 'x'){...}
Remove del for email
.
- References:
- Prev by Date: Re: Include path question
- Next by Date: Re: assembly in future C standard
- Previous by thread: Re: Structures or Array Notation for many possible strings of finite length?
- Next by thread: Sort it with one array and some tmp files
- Index(es):
Relevant Pages
|