C examples for File:File Operation
Opens existing file and adds a line to the end
#include <stdio.h> #include <stdlib.h> FILE * fptr;/*w w w .j ava 2 s . com*/ int main() { fptr = fopen("C:\\test\\BookInfo.txt","a"); if (fptr == 0) { printf("Error opening the file! Sorry!\n"); exit (1); } fprintf(fptr, "\nthis is a test!\n"); fclose(fptr); return(0); }