Could you first explain us what your program is supposed to do, and how the -r command line parameter should affect its output, so we don't have to puzzle everything out?
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
So why the double open?
f = fopen(p, "w");
fprintf(f, "");
fclose(f);
f = fopen(p, "a");
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953