PC Review


Reply
 
 
Gil
Guest
Posts: n/a
 
      6th Aug 2008
Hi everyone,

I have a function which writes some data into file. This is its interface:

void WriteDataToFile(FILE*);

I want to use it to buffer my data into memory instead of writing it into
disk-file. For that, I am using _fdopen as follows:

FILE *sptr=_fdopen( 0, "w" );
char buf[48000];
memset(buf, '\0', sizeof(buf));
setvbuf( sptr, buf, _IOFBF, sizeof( buf ) );
WriteToFile(sptr);

It seems working.
However, I suspect his code to cause my application to sometimes hang and
even crash. Could this code be the problem? What is the exact return value of
this call..:

_fdopen( 0, "w" );

Can I trust the FILE returned value and write to it?

Thanks,
Gil.

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      6th Aug 2008
This newsgroup is for questions about coding in VBA (specifically in Access,
the database product that's part of Office Professional).

Your code snippet would appear to be C or some variation thereof. You'd be
better off reposting your question to a more appropriate newsgroup.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Gil" <(E-Mail Removed)> wrote in message
news:7E238B5E-767E-44D1-938A-(E-Mail Removed)...
> Hi everyone,
>
> I have a function which writes some data into file. This is its interface:
>
> void WriteDataToFile(FILE*);
>
> I want to use it to buffer my data into memory instead of writing it into
> disk-file. For that, I am using _fdopen as follows:
>
> FILE *sptr=_fdopen( 0, "w" );
> char buf[48000];
> memset(buf, '\0', sizeof(buf));
> setvbuf( sptr, buf, _IOFBF, sizeof( buf ) );
> WriteToFile(sptr);
>
> It seems working.
> However, I suspect his code to cause my application to sometimes hang and
> even crash. Could this code be the problem? What is the exact return value
> of
> this call..:
>
> _fdopen( 0, "w" );
>
> Can I trust the FILE returned value and write to it?
>
> Thanks,
> Gil.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:19 PM.