Is it ok to call fcloseall() when using both C-style FILE * and C++
std::ofstream's to read files in a program?
Thanks,
Dave 2 2368
On Mar 18, 6:45*pm, Jack Klein <jackkl...@spam cop.netwrote:
On Tue, 18 Mar 2008 11:20:26 -0700 (PDT), Dave Johansen
<davejohan...@g mail.comwrote in comp.lang.c++:
Is it ok to call fcloseall() when using both C-style FILE * and C++
std::ofstream's to read files in a program?
Thanks,
Dave
No idea. *There is no "fcloseall( )" function in either the standard C
or the standard C++ library. *So you will have to consult the provider
to find out what it does or does not do.
--
Jack Klein
Home:http://JK-Technology.Com
FAQs for
comp.lang.chttp ://c-faq.com/
comp.lang.c++http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
I did a little more research and it is actually a GNU and Microsoft
extension, but it causes problems when using static/global fstream's
because the destructors try to close the FILE * that has already been
closed.
Dave This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: m vaughn |
last post by:
I wanted to hold information about open files in a struct and be able
pass it around, but the behavior is not what I would expect. Can
someone tell me why this doesn't work? (Even better, what is the
proper way to do this, eg, without the pointers and such). As is
probably obvious, I am not terribly knowledgable here.
The *fs.of<< ... statement in main() does nothing in gcc 3.2.2 and
gives a seg fault in gcc 3.2 (Mandrake linux 9.1 and...
|
by: red floyd |
last post by:
Is there any way to retrieve the filename given to a std::ofstream
(passed in constructor or in ofstream::open())?
Or, should I derive from ofstream (should probably be a template to
handle ifstream and fstream as well, but I'm typing on the fly)
yes, I know the syntax may be off...
class onamedfstream : public ofstream {
|
by: Chase Bradford |
last post by:
Hey all
I have a class Foo, and I'm trying to overload the << operator for both
the ostream and ofstream for it. This way I should have two seperate
formats for output, one for files and another for the screen. Right now the
two declarations are:
std::ofstream& operator<<( std::ofstream &fos, const Foo &theClass);
std::ostream& operator<<( std::ostream &fos, const Foo &theClass);
|
by: jois.de.vivre |
last post by:
Hi,
I'm trying to write to an ofstream, and for some reason it fails. I
know I can check it with fail() or bad(), but it gives me no useful
information as to why it fails. Are there any C++ functions that do
this or is there any way I can check manually?
Thanks,
Prashant
|
by: davihigh |
last post by:
My Friends:
I am using std::ofstream (as well as ifstream), I hope that when i
wrote in some std::string(...) with locale, ofstream can convert to
UTF-8 encoding and save file to disk. So does ifstream.
Something I found shows that, I need to have a proper codecvt to set
it. I need more information, maybe a small piece of code sample. Thank
you!
| |
by: bob |
last post by:
Hi,
I'm working with an ofstream object and using it to print the contents
on an 100 * 100 matrix. i.e. lots of elements. the _matrix variable
below is defined as std::vector<std::string, std::string>
When I run the code below I see the TTK_LOG( our logging function) call
correctly outputting all the values in the matrix. However I never see
anything output to the ofstream. (there's other data put into the
ofstream object elsewhere...
|
by: thinktwice |
last post by:
//case 1, works fine
function(..)
{
std::ofstream out;
out.open(file);
out << "error info" <<endl;
out.close();
}
//case 2, declare it in a class
|
by: Joe Hesse |
last post by:
Hi,
I have a C++ function that writes to an ofstream object.
I would like to sometimes use it to write to cout.
I realize that cout is of type ostream which is not ofstream.
Since cout is "kind of" an output file, there should be someway to do it.
The following code shows what I am trying to do.
------------------------------------------------
#include <iostream>
#include <fstream>
|
by: aaragon |
last post by:
Hello, does anyone have a clue about this error? and how to solve it?
It seems to be trivial to me, but not for the compiler. I'm using g++
4.2 on an Ubuntu Linux system:
// main()
....
std::ofstream fout;
fout.open("hello.out");
fout<<setfill('-')<<setw(20)<<"-"<<setfill(' ')<<endl;
fout<<"hello "; // this is line 139
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |