473,503 Members | 8,784 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 1609
po***********@gmail.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***********@gmail.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***********@gmail.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**********************@z14g2000cwz.googlegroups .com>,
ab********@yahoo.co.in <ab********@yahoo.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********@yahoo.co.in"
<ab********@yahoo.co.in> wrote in comp.lang.c:

po***********@gmail.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.learn.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
3039
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...
3
5114
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...
5
2238
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...
3
6404
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
3544
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...
6
1336
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...
2
1428
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 ...
2
1669
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...
4
11930
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...
0
7194
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,...
0
7267
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,...
1
6976
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...
0
7449
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...
0
5566
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,...
0
4666
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...
0
3160
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...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
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...

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.