In this program we will learn How to append data into a file.
EX: Write a C program to append data into a file, How to write a C program to append contents into a file. C program to append data into a file.
C Program to append data into a file:
#include<stdio.h>
#include<string.h>
int main()
{
FILE *fptr;
char str[100];
//Open file in append mode
fptr = fopen("file.txt","a");
//Input data to append
printf("Enter data to append:\n");
gets(str);
//Append data to a file
fputs(str,fptr);
printf("Your data appended in file successfully :) ");
fclose(fptr);
return 0;
}
File Contents before appending:
Output after appending data into the file:
Learn more: file handling examples...
No comments:
Post a Comment
If you have any doubts, please discuss here...👇