global parameters
Hello All.
I'd like to ask one question.
I've got a programm, and i'd like to read configuration from file. I need in some data structure for it.
What is the best way to do it?
I see at least two ways.
The first is allocate a structure like this
struct somestruct {
param1;
param2;
.
.
paramn; }
and create func what will fill and return pointer to it, that I can use in any place.
The Second way is to
allocate some global variables and make them available through "extern" in other modules.
Can anybody point me at advantages and disadvantages of this methods.
Eugene Vigovskiy
----- Original Message -----
From: "Eugene Vigovskiy" <[email protected]>
Newsgroups: ka.lists.linux.c.programming
Sent: Friday, April 19, 2002 9:48 AM
Subject: global parameters
Quoted 12 lines
Hello All.
I'd like to ask one question.
I've got a programm, and i'd like to read configuration from file. I need in some data structure for it.
What is the best way to do it?
I see at least two ways.
The first is allocate a structure like this
Quoted 8 lines
struct somestruct { param1; param2; . . paramn;}
and create func what will fill and return pointer to it, that I can use
in any place.
Quoted 9 lines
The Second way is to
allocate some global variables and make them available through "extern" in other modules.
Can anybody point me at advantages and disadvantages of this methods.
Quoted 4 lines
Eugene Vigovskiy
-
To unsubscribe from this list: send the line "unsubscribe
linux-c-programming" in
Quoted 6 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--------------------------------------------------------------------------
-----
Quoted 1 line
Achtung: diese Newsgruppe ist eine unidirektional gegatete
Mailingliste.
Quoted 3 lines
Antworten nur per Mail an die im Reply-To-Header angegebene Adresse.
Fragen zum Gateway -> [email protected].
--------------------------------------------------------------------------
-----
I think the first one is better.
(If you want to develope this program, you only let these modules see
the declarations that realy need them)
If it going to be small (~200 Lines) then it doesn't matter which one you use.