Try doing something like this
const char Logfile = '/usr/people/bob/APHOME/applogfile'
FILE *fp
remove("LogFile");
fp = fopen("LogFile", "w");
.
.
.
What it sounds like is that your #define isn't getting the entire path to
the file so it's just doing what it can with what it knows, which is the
directory where the program lives.
> I'm writing a program and i have the following question. I'm defining a
> homedirectory and logfile for my application like this
>
> #define LOGFILE /APPHOME/applogfile /* APPHOME is the actual home
> directory for the application */
>
> But when i try to delete the old logfile and open the logfile like below, it
> doesn't work (it won't access the file described as above, instead, it
> creates a file LOGFILE in the directory where i run the program.
>
> FILE *LogFile;
> remove("LOGFILE"); /* First remove the old logfile */
> LogFile = fopen("LOGFILE", "w");
>
> .
> .
> do some stuff
> .
> .
> fclose("LOGFILE");
>
> What is the problem ?
>
> De Messemaeker Johan
> HEMMIS n.v.
> Koning LeopoldIII-laan 2, 8500 Kortrijk
> Tel.: 32 (0)56/37.26.37
> Fax: 32 (0)56/37.23.24
> Current Project : VMM Aalst
>