Thread View: comp.std.c
7 messages
7 total messages
Started by christian felique
Fri, 29 Mar 1996 11:44
Close all opened files in C ?
Author: christian felique
Date: Fri, 29 Mar 1996 11:44
Date: Fri, 29 Mar 1996 11:44
37 lines
1431 bytes
1431 bytes
I am using a shareware C routine to play a sound sample
throught the PC speaker.
SoundPlay("SAMPLE.VOC",delay,twiddle);
I think that the programmer
of the routine has forgotten to take care of closing the sample file
after it is played, because the routine will not work anymore after a few
calls (about 10 calls) (It displays an Out of Memory message)
I think that the Out of Memory error has got nothing to
do with the size of a sound sample file, because:
* You can call the routine for about 10 times using a small sample.
* " " " " " """"""""""""""10 """"""""""""large """""""
According to me, the reason for the out of memory error
is the fact that there are too many file buffers open .
NOW THIS IS MY QUESTION:
How can I close all files that are opened ?
I can't use fclose(...) because fclose needs a file pointer as
an argument.
If you know how to solve this problem in Quick C or
inline assembly. Then send me your answer
to:
CHRISTIAN.FELIQUE@STUDENT.KULEUVEN.AC.BE
Re: Close all opened files in C ?
Author: walter briscoe
Date: Fri, 29 Mar 1996 13:17
Date: Fri, 29 Mar 1996 13:17
59 lines
2540 bytes
2540 bytes
In article <4jgifa$fjd@chaos.kulnet.kuleuven.ac.be>
christian.felique@student.kuleuven.ac.be "christian felique" writes:
> I am using a shareware C routine to play a sound sample
> throught the PC speaker.
>
> SoundPlay("SAMPLE.VOC",delay,twiddle);
>
>
> I think that the programmer
> of the routine has forgotten to take care of closing the sample file
> after it is played, because the routine will not work anymore after a few
> calls (about 10 calls) (It displays an Out of Memory message)
>
> I think that the Out of Memory error has got nothing to
> do with the size of a sound sample file, because:
>
> * You can call the routine for about 10 times using a small sample.
> * " " " " " """"""""""""""10 """"""""""""large """""""
>
> According to me, the reason for the out of memory error
> is the fact that there are too many file buffers open .
>
>
> NOW THIS IS MY QUESTION:
>
> How can I close all files that are opened ?
>
> I can't use fclose(...) because fclose needs a file pointer as
> an argument.
>
> If you know how to solve this problem in Quick C or
> inline assembly. Then send me your answer
> to:
This thread is inappropriate in comp.std.c.
Not as inappropriate as the "help wanted" threads which recently
appeared and I ignored those.
I suggest comp.lang.c.moderated may be appropriate.
My first thought was that fclose ( 0 ) should do the job by analogy with
fflush ( 0 ) but the standard library is not orthogonal.
I don't know quickc's limitations but in Borland C++ 3.1 can:
#include <stdio.h> or #include <io.h>
(void)fcloseall int i = 6; while (!close(i++));
or the assembly to close a file with a given handle is:
mov bx, Handle ; Handle of file or device
mov ah, 3Eh ; Close File with Handle
int 21h ; Do it
jc error_handler ; carry set on error
ax contains a standard DOS error code on failure.
--
walter briscoe
Re: Close all opened files in C ?
Author: Peter Seebach
Date: Fri, 29 Mar 1996 21:59
Date: Fri, 29 Mar 1996 21:59
20 lines
1077 bytes
1077 bytes
In article <828105458snz@wbriscoe.demon.co.uk>, walter briscoe <walter@wbriscoe.demon.co.uk> wrote: [re:] >> NOW THIS IS MY QUESTION: >> How can I close all files that are opened ? >This thread is inappropriate in comp.std.c. >I suggest comp.lang.c.moderated may be appropriate. Probably not; I'd bounce it with "you can't in C, try a newsgroup specific to your system." -s -- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach. C/Unix wizard -- C/Unix questions? Send mail for help. No, really! FUCK the communications decency act. Goddamned government. [literally.] The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
Re: Close all opened files in C ?
Author: Dan Pop
Date: Sun, 31 Mar 1996 02:36
Date: Sun, 31 Mar 1996 02:36
25 lines
1178 bytes
1178 bytes
In <4jhmg0$50n@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes: >In article <828105458snz@wbriscoe.demon.co.uk>, >walter briscoe <walter@wbriscoe.demon.co.uk> wrote: >[re:] >>> NOW THIS IS MY QUESTION: > >>> How can I close all files that are opened ? > >>This thread is inappropriate in comp.std.c. > >>I suggest comp.lang.c.moderated may be appropriate. > >Probably not; I'd bounce it with "you can't in C, try a newsgroup >specific to your system." And you'd be dead wrong. exit() _will_ close all the files that are opened :-) Dan -- Dan Pop CERN, CN Division Email: danpop@mail.cern.ch Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
Re: Close all opened files in C ?
Author: Eric W. Biederman
Date: Mon, 01 Apr 1996 07:16
Date: Mon, 01 Apr 1996 07:16
24 lines
1236 bytes
1236 bytes
In article <4jhmg0$50n@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes: In article <828105458snz@wbriscoe.demon.co.uk>, walter briscoe <walter@wbriscoe.demon.co.uk> wrote: [re:] >> NOW THIS IS MY QUESTION: >> How can I close all files that are opened ? >This thread is inappropriate in comp.std.c. >I suggest comp.lang.c.moderated may be appropriate. Probably not; I'd bounce it with "you can't in C, try a newsgroup specific to your system." I'm not absolutely positive it's in the standard, but I do believe either you find each on and close it. OR call exit. OR return from main. can someone confirm the second two? Eric
Re: Close all opened files in C ?
Author: Peter Curran
Date: Mon, 01 Apr 1996 15:41
Date: Mon, 01 Apr 1996 15:41
27 lines
1795 bytes
1795 bytes
On 01 Apr 1996 07:16:38 GMT in article <ERIC.96Apr1011638@cse.unl.edu>
Eric W. Biederman <ebiederm@cse.unl.edu> (Eric W. Biederman) wrote:
>In article <4jhmg0$50n@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes:
> In article <828105458snz@wbriscoe.demon.co.uk>,
> walter briscoe <walter@wbriscoe.demon.co.uk> wrote:
> >> How can I close all files that are opened ?
>I'm not absolutely positive it's in the standard, but I do believe
>either you find each on and close it. OR call exit. OR return from
>main.
>can someone confirm the second two?
The original poster's question did not indicate that the code that opened the
files was written in C. Since it is concerned with operating a machine-specific
hardware device, it could well be written in assembly language, or some other
language, with a C-usable API. If that is the case, the C run-time system would
know nothing about the files, so none of the mechanisms would be guaranteed to
work. In most environments terminating the program (i.e. calling exit() or
returning from main()) will work because the OS takes care of it, but the C
standard guarantees nothing in such a situation.
--
Peter Curran pcurran@inforamp.net
Re: Close all opened files in C ?
Author: Christopher R Volpe
Date: Tue, 02 Apr 1996 21:28
Date: Tue, 02 Apr 1996 21:28
14 lines
1005 bytes
1005 bytes
christian felique wrote: > > I am using a shareware C routine to play a sound sample > throught the PC speaker. [rest of problem deleted] This really has nothing to do with comp.std.c, so I am crossposting and redirecting followups to comp.lang.c.moderated. -- Chris Volpe Phone: (518) 387-7766 (Dial Comm 8*833 GE Corporate R&D Fax: (518) 387-6560 PO Box 8, Schenectady, NY 12301 Email: volpecr@crd.ge.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads