Author Topic: Write in file without deleting its contents  (Read 4124 times)

Offline pion

  • Multiple posting newcomer
  • *
  • Posts: 10
Write in file without deleting its contents
« 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?

Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: Write in file without deleting its contents
« Reply #1 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
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline pion

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Write in file without deleting its contents
« Reply #2 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!