Neelkanth_221$ cat text.c
#include <stdio.h>int main () {
FILE *fp;
fp = fopen("file.txt","a+");
fprintf(fp, "I am Neelkanth Reddy\n");
fprintf(fp, "I live on planet earth\n");
fclose(fp);
return(0);
}
execute the code 5 times
Neelkanth_221$ vi text.c
Neelkanth_221$ vi text.c
Neelkanth_221$ gcc text.c
Neelkanth_221$ ./a.out
Neelkanth_221$ ./a.out
Neelkanth_221$ ./a.out
Neelkanth_221$ ./a.out
Neelkanth_221$ ./a.out
Output:
Neelkanth_221$ cat file.txt
I am Neelkanth Reddy
I live on planet earth
I am Neelkanth Reddy
I live on planet earth
I am Neelkanth Reddy
I live on planet earth
I am Neelkanth Reddy
I live on planet earth
I am Neelkanth Reddy
I live on planet earth