I am writing code so that at each iteration of the for loop, functions are executed that write data to a file, for example:
int main()
{
int i;
for(i = 0; i < 100; i++) writedata();
return 0;
}
void writedata()
{
FILE *data;
data = fopen("output.dat", "a");
...
}
How can I get it so that when I start the program it will delete the contents of the file at the beginning of the program, but after that it will add data to the file? I know that using the identifier "w" in fopen () will open a new empty file, but I want to be able to "add" data to the file every time it performs the function "writedata ()", therefore, using the identifier "a".
source
share