Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: pion on September 04, 2021, 11:00:21 am

Title: Write in file without deleting its contents
Post by: pion on September 04, 2021, 11:00:21 am
Hello again,

I have stored some numbers in a text file and I want to read these numbers when starting my program. As far as I know, if I want to use a file in my program, I need to use fopen("file.txt", "w"), which clears the contents of the file. Is there a way to read and write a file without having to delete what's in it first, so that I can use the file to store long term information?
Title: Re: Write in file without deleting its contents
Post by: gd_on on September 04, 2021, 12:12:51 pm
next time, use a general programming forum, not this one !
For example have a look in https://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm
Title: Re: Write in file without deleting its contents
Post by: pion on September 04, 2021, 12:37:52 pm
Sorry, I didn't know this was only for Codeblocks questions. I think I found an answer to my problem, thanks!