linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* named structure members
@ 2003-09-11 11:07 Matthew Harrison
  2003-09-11 11:50 ` Jeff Woods
  2003-09-11 14:03 ` Mariano Moreyra
  0 siblings, 2 replies; 15+ messages in thread
From: Matthew Harrison @ 2003-09-11 11:07 UTC (permalink / raw)
  To: linux-c-programming

[-- Attachment #1: Type: text/plain, Size: 1865 bytes --]

hi,
  another one for you gurus, i haven't found anything on this myself
as i don't really know what to call it where a search engine is
concerned.

i have the following code.

<snip>
for(i = 0; i < n_values; ++i)
        {
                strcpy(keyword, good_values[i]);

                switch (read_config_var(values_file, keyword, value))
                {
                        case 0:
                                strcpy(config.?, value);
                                break;
                        case -1:
                                printf("\nFile Error for [%s] \n", values_file);
                                break;
                        case -2:
                                printf("\nBad User Parm for [%s] \n", keyword);
                                break;
                        default:
                                printf("\nUnknown Error Occurred \n");
                                break;
                }
        }
</snip>

what i'm doing is stepping thru an array of different config options
calling the read_config_var on each one and checking the output.
if the output is good then i want to store the value in a member of
a structure. for example i want the config options to be stored like
this:

config.db_host = 'maiden.genestate.com'
config.db_user = 'root'

you get the idea. my question is how do i dynamically assign a name
to a structure member. I have good_values[i] which contains the
current config directive but if you look at line 8 of the example,
you can see the problem, how do i say config.good_values[i], when
good_values[i] is not itself a member.

sorry for not being able to explain this very well but you can see
what i mean.

thanks in advance

-- 
Mat Harrison
Technical Developer
3d Computer Systems Ltd.
matth@3d-computers.co.uk

[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2003-09-12 14:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-11 11:07 named structure members Matthew Harrison
2003-09-11 11:50 ` Jeff Woods
2003-09-11 14:03 ` Mariano Moreyra
2003-09-11 14:26   ` Matthew Harrison
2003-09-11 14:41     ` Mariano Moreyra
2003-09-11 15:28       ` Matthew Harrison
2003-09-11 15:35         ` Mariano Moreyra
2003-09-11 15:42           ` Matthew Harrison
2003-09-11 15:50     ` Glynn Clements
2003-09-11 16:52       ` Jan-Benedict Glaw
2003-09-11 17:13         ` Matthew Harrison
2003-09-12 13:22           ` Mariano Moreyra
2003-09-12 13:47             ` Matthew Harrison
2003-09-12 13:52               ` Mariano Moreyra
2003-09-12 14:33                 ` Matthew Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).