G
Guy Garty
Hi,
I have a problem with a function returning a FILE * value
(I am using gcc on Red hat enterprise 5, 64bit)
My function is supposed to open a file and return a pointer to it:
#include <stdio.h>
FILE *OutFile[10];
FILE *OpenLog(int x, int y, int h, int w, char *LogString)
{
[....]
if ((OutFile[j]=fopen(FileName,"w"))==NULL)
{
OutFile[j]=stdout;
}
[...]
return OutFile[j];
}
The first few times, it works ok, returning values like 0x37849c0.
After the third or fourth call, fopen starts returning values like
0x2aaab00da680. These values are not NULL and the file appears to be
created properly, however the value returned by my function is now
0xffffffffb00da680 and all hell breaks loose (Segmentation Fault when
accessing the file).
What is going on here?
guy
I have a problem with a function returning a FILE * value
(I am using gcc on Red hat enterprise 5, 64bit)
My function is supposed to open a file and return a pointer to it:
#include <stdio.h>
FILE *OutFile[10];
FILE *OpenLog(int x, int y, int h, int w, char *LogString)
{
[....]
if ((OutFile[j]=fopen(FileName,"w"))==NULL)
{
OutFile[j]=stdout;
}
[...]
return OutFile[j];
}
The first few times, it works ok, returning values like 0x37849c0.
After the third or fourth call, fopen starts returning values like
0x2aaab00da680. These values are not NULL and the file appears to be
created properly, however the value returned by my function is now
0xffffffffb00da680 and all hell breaks loose (Segmentation Fault when
accessing the file).
What is going on here?
guy