how to write only one parameter in a file

P

poison.summer

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!
 
L

Logan Shaw

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
 
J

Joe Wright

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?
 
A

abdur_rab7

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
 
K

Kenny McCormack

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.
 
J

Jack Klein

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top