473,657 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write only one parameter in a file

Hello I need to write and read a parameter through a file to get
communication between two processes.
I know how to use fopen, fprintf. But I wonder how can I overwrite the
old files.
For instance, I need to write the value of A into a file. Another
process need to access the data of A.
Then the first process will overwrite the value of A.

How can I do that?

Thanks a lot!

Jan 18 '06 #1
5 1615
po***********@g mail.com wrote:
Hello I need to write and read a parameter through a file to get
communication between two processes.
I know how to use fopen, fprintf. But I wonder how can I overwrite the
old files.
For instance, I need to write the value of A into a file. Another
process need to access the data of A.
Then the first process will overwrite the value of A.


Do a

rewind (file);

before you use fprintf() on the file.

- Logan
Jan 18 '06 #2
po***********@g mail.com wrote:
Hello I need to write and read a parameter through a file to get
communication between two processes.
I know how to use fopen, fprintf. But I wonder how can I overwrite the
old files.
For instance, I need to write the value of A into a file. Another
process need to access the data of A.
Then the first process will overwrite the value of A.

How can I do that?

Thanks a lot!

As you have tried to do it, what problems do you have?

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Jan 19 '06 #3

po***********@g mail.com wrote:
Hello I need to write and read a parameter through a file to get
communication between two processes.
I know how to use fopen, fprintf. But I wonder how can I overwrite the
old files.
For instance, I need to write the value of A into a file. Another
process need to access the data of A.
Then the first process will overwrite the value of A.

How can I do that?

Thanks a lot!


Insted of using files for giving communication between two process, you
can use either sockets or shared memory to do that

Best Regards,
Abdur

Jan 19 '06 #4
In article <11************ **********@z14g 2000cwz.googleg roups.com>,
ab********@yaho o.co.in <ab********@yah oo.co.in> wrote:
....
Insted of using files for giving communication between two process, you
can use either sockets or shared memory to do that


Allow me to be the first to say this - and I say it from the deepness of my
heart, with all the kindness and love one has come to associate with the
helpful posts you get in this newsgroup:

Not portable. Can't discuss it here. Blah, blah, blah.

Jan 19 '06 #5
On 18 Jan 2006 20:42:18 -0800, "ab********@yah oo.co.in"
<ab********@yah oo.co.in> wrote in comp.lang.c:

po***********@g mail.com wrote:
Hello I need to write and read a parameter through a file to get
communication between two processes.
I know how to use fopen, fprintf. But I wonder how can I overwrite the
old files.
For instance, I need to write the value of A into a file. Another
process need to access the data of A.
Then the first process will overwrite the value of A.

How can I do that?

Thanks a lot!


Insted of using files for giving communication between two process, you
can use either sockets or shared memory to do that


The C language does not have sockets or shared memory. If your
platform does, it is a non-standard extension. And just because your
platform does, it does not mean that the OP's platform has the same
non-standard extensions.

And by the way, non-standard extensions are off-topic here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jan 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3046
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers to have an easier time understanding what I do. Therefore this weekend I'm going to spend 3 days just writing comments. Before I do it, I thought I'd ask other programmers what information they find useful. Below is a typical class I've...
3
5135
by: Mark Miller | last post by:
I have a char array and when I write it to a file using BinaryWriter the position of the pointer is the size of the array + 1. For example: writing char leaves the pointer at position 26 after starting at position 0. I thought that char was 2 bytes, but this makes it seem as though it is just 1 when I write to a file. Why is this? I imagine the extra bit is just a null bit (correct me if I'm wrong). I don't know if this helps but when I...
5
2251
by: Just Me | last post by:
Using streams how do I write and then read a set of variables? For example, suppose I want to write into a text file: string1,string2,string3 Then read them later. Suppose I want to write and then read: string1, integer1, double1
3
6425
by: Laszlo Nagy | last post by:
This program: import sys import traceback import cStringIO a = 1.0 b = 0.0 try: c=a/b
0
3559
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
6
1341
by: Demorsy | last post by:
Disappointed, this is not the first time I'm posting this kind of a request for help, but no helpful answer was posted yet. I'll try make my question as clear as I can: (1) I wish to write an XML file. this file will contain any number of parameters to be used in my C# code as database. (2) This file may contain any number of parameters, and I will know the number of the parameters only at run time. (3) Any parameter must have a name,...
2
1443
by: Flyzone | last post by:
I have a list of parameters. I need to run in thread a command, one thread for one parameter. So i made a for loop, creating 5 threads and waiting their stop with: for parameter in parameters Thread{ .... write on BW2 .... }
2
1681
by: cmrhema | last post by:
Hi All , I have with me a server socket program, I am receiving all the clients, but what happens is i have to write it into a file. This consumes time. So we do not have a data loss, but as the time taken to write into the log file increases, some of the data does not get written. This is the code //ONLY SHOBA
4
11949
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the dialog box has as the default file name the name of this ashx file. I'd like to make that name more meaningfull but don't know how it gets set. I'm looking for a Response.Write but don't find one. Maybe that why the
0
8385
marktang
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...
0
8303
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,...
0
8821
Oralloy
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...
1
8502
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,...
0
8602
tracyyun
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...
0
7316
agi2029
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...
1
6162
isladogs
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...
0
5632
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();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.