Click here to Skip to main content
Rate this:
 
Please Sign up or sign in to vote.
See more: C
Hi,

I want to create a file if its not exist and nees to open it in append mode.
so fopen with "a+" works for creation and appending a file?

Help me out.
Thanks in advance.
Posted 2-May-10 20:33pm
Edited 2-May-10 20:34pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Poonamol wrote:
fopen with "a+" works for creation and appending a file

Yes!

"a+": Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Web03 | 2.8.160208.1 | Advertise | Privacy
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100