You are here:

C/Followup questions on my very first question

Advertisement


Question
Thanks for your fast reply! I used 'r+' to open the file. According to my reference book (deitel & deitel), 'r+' should allow us to read and write as well, isn't it? Anyway, I will follow your advise to write the new content to another file and then rename it to the source file. :)

Answer
May be what you said regarding "r+" is correct.
But, most of the times we use "a" for reading and writing.

Since you didn't give the error string that you got when you executed the code, I tried to guess what could be wrong.
And I noticed "r+". May be "r+" is correct and something else also could be wrong.
If you could elaborate more on the error that you got, then we can try to refine our guess:-)

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.