f



[C file I/O (via mex)] content written to file is only present if matlab is closed

Hello,

I have c-function interfaced via mex.

Inside this function several file streams are opened, content is
written using fprintf() and the files are closed.

Some file descriptors are defined within the function scope,
opened there, written there and closed there.
With these files all is fine.

But one file descriptor is declared globally, opened in one function,
written to in another and finally closed in the function, where it
has been opened.
The problem with this file is, that after a successful call of the
mex function, the file size is 0 bytes.
The file is opened with "w" and it has existed with content before.
So the file is opened and cleared as it should be.
But the content is yet not written to it, like it is done with the
other files.
Only if I close MATLAB the file is updated with the content i wrote
to it.

What could be the reason for this behavior?

Regards,
Robert
0
masked (25)
5/24/2007 10:58:02 AM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
596 Views

Similar Articles

[PageSpeed] 54

Well,

I solved it.

Right after the fprintf() call in the one function it now calls
fflush().

The flush beeing done automatically by fclose within the other
function scope seems not to be sufficient.
0
masked (25)
5/24/2007 11:08:20 AM
Reply: