append character to a file

Hi,
fputc() will overwrite from the beginning of the target file.
How would I append characters to the target file's end instead?
Thanks.

either

FILE *fp=fopen(filename,"a");
fputc('q',fp);
fclose(fp);

or

int fd=open(filename,O_WRONLY);
char buf[1];
buf[0]='q';
lseek(fd,0L,SEEK_END);
write(fd,buf,1);
close(fd);

So it seems it is the way you open the file that determines whether the new stuff will overwrite what is there or be appended to it.
I have been using;

FILE *fp=fopen(filename,"w");
fputc('q',fp);
fclose(fp);

I should use;

FILE *fp=fopen(filename,"a");
fputc('q',fp);
fclose(fp);

If you open in 'w'

this is what happens

  w      Truncate  file  to  zero length or create text file for writing.
              The stream is positioned at the beginning of the file.