help in ow to append a text file ... a simple programme source code since willl be having exam 2morrow thank you

Recommended Answers

All 2 Replies

hndl = fopen("file.txt", "r+");
fseek(hndl, 0, SEEK_END);
   
fprintf(hndl, "some text");
   
fclose(hndl);

if you're using C++:
1st thing to do:

#include <fstream>

2nd thing open the file for output obviously if you're going to append and change the default behaviour of ofstream:

ofstream fout(<filename>, ios::app)

Then go on with your program. Dont forget to close your file at the end!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.