(I've not done C prorgamming in such a long time, I have forgotten how
to do this.)
I'm writing a program, where it fopens a file with "a+", and I want to
be able to continue writing to this file, but I want the program to
exit(1) if the disk is full or some other write failure. I would like
to see a C code example. Thanks in advance!
Dec 13 '06
10 2343
On Thu, 14 Dec 2006 13:32:55 +0000, Richard Heathfield wrote:
>If your intent is to write a string up to but not including its terminating null character, then you'll want to use strlen rather than sizeof.
Also, 'fclose' with checked return value would be nice for code that
'fopen's a file and tries to detect "if the disk is full or some other
write failure" (fflush with checked return value may be helpful, too).
Best regards,
Roland Pibinger This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joseph |
last post by:
Hi
I'm writing a commercial program which must be reliable. It has to do
some basic reading and writing to and from files on the hard disk,
and also to a floppy.
I have foreseen a potential problem. The program may crash
unexpectedly while writing to the file. If so, my program should
detect this during startup, and then (during startup) probably delete the
data added to the file and redo the writing operation.
|
by: Lu |
last post by:
Hi there,
I got a program to write data to a randomly accessed file (the program
moves file pointer to a certain position of the file according the
current "keyword" and then writes data). It compiles and runs in Win2K
and various Unix and Linux systems. The main program is in Fortran,
calling a data writing library writen in C++.
The weird thing is, it takes much longer elapse time (wall-clock time)
than CPU time (e.g., 20 min vs. 2...
|
by: Mr. Smith |
last post by:
Hello all,
My code can successfully open, write to, format and save several
worksheets in a workbook then save it by a given name, close and quit excel.
My problem is that if I try and do it again, Excel hangs. OR if I open
Excel again (say from a desktop icon) before I close Access, Excel
hangs. (this has happened for both 97 & 2000 for me)
I of course thought that I mustn't be unloading a variable properly.
|
by: Bruce Dodds |
last post by:
One of my clients is going to move to CD or DVD as a medium to
backup/transfer data. Is it possible for an A2003 application to write
directly to a CD or DVD under Win XP, or will I need to set up an
external script?
TIA,
Bruce
|
by: phantom |
last post by:
Hi All.
I am having a problem writing to a file. I can successfully open the
file and write the contents using fprintf, however if the writing is
not done for a while in the process the file write returns a status
-1.
To elaborate here is the code segment
main (... , ...)
{
| |
by: iwdu15 |
last post by:
how can i open a file i saved and place the info into different text boxes?
|
by: riggor |
last post by:
I have been searching for answers to this question ... but all I have found
is other people asking the same question..but I have not found an answer...
I am trying to install Oracle 10g on Solaris 10 on x86. When I run the
installer I get the following error message:
"Error in writing to directory /tmp/OraInstall2006-10-12_05-05-40PM. Please
ensure that this directory is writable and has atleast 69 MB of disk space.
Installation...
|
by: rmr531 |
last post by:
First of all I am very new to c++ so please bear with me. I am trying
to create a program that keeps an inventory of items. I am trying to
use a struct to store a product name, purchase price, sell price, and
a taxable flag (a Y/N char) and then write this all out to a file
(preferably just a plain old text file) and then read it in later so
that I can keep a running inventory. The problem that I am running
into is when I write to the...
|
by: Shawn |
last post by:
Hello:
I have the following code in a PHP file. An HTML form passes user
comment data to the PHP, which then appends the user comments to the
end of the HTML file on which the form is located. This PHP code
works: the HTML file with added comments displays correctly in my
browser. However, appending text to the very end of the HTML file
creates what is, strictly speaking, invalid code.
I am looking for a way to tell PHP to write data to...
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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.
| | |