26. write a C program to append data to the file


Program to append data to the file.

Source Code:

#include <stdio.h>
int main()
{
   FILE *fp;
   char str[80];
     fp = fopen("/home/smec/Desktop/hello.txt", "a");
     printf("Enter your message:");
   scanf("%s",str);
     fprintf(fp, "%s",str);
     printf("Your message is appended in data.txt file.");
   fclose(fp);
   return 0;
}

Output: 

 Enter your message:Learn_C
Your message is appended in hello.txt file.
 before append hello.txt








 
 
After append hello.txt



No comments:

Post a Comment