Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get fresh copy of #include "myconf.h" ??

Status
Not open for further replies.

perlguy

Programmer
May 17, 2001
26
US
I have stored my some variable inside "myconf.h" as shown below :

/* begin myconf.h variable section */
char name[20] = "tommy";
int age = 26;
/* end of myconf.h */

here is my main C prg. "hello.c" :

#include <stdio.h>
#include <stdlb.h>
#include &quot;myconf.h&quot;

int main(void)
{
printf (&quot;Your name : %s &quot;, name);
printf (&quot;Your age : %d &quot;, age);

return(0);
}

When I run the program , it prints the correct values.
Now let say I change the values of variables insdie &quot;myconf.h&quot; file eg. &quot;robert&quot; & 28 to name and age respectively. When I run the program(without compiling) it still gives me same old values i.e. &quot;tommy&quot; , 26.
WHY SHOULD I COMPILE everytime when I change in &quot;myconf.h&quot; ??

Is ther anyway I can achieve this without compiling everytime C prg.?
Appreciated.
 
#include directives just &quot;paste&quot; the contents of the file named as is where the #include is placed. There is no magic here. Yes.... You have to re-compile everytime you change your source code if you want the changes to be relected in the EXE
What you may want to do instead, is place your info in a file called myconf.ini, and then load (see fopen, fgetc, etc) and parse the file data with your program. Then all the user has to do is modify the myconf.ini file. This will result in more complex code, but your program will be more flexable.


Kim_Christensen@telus.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top