1#include <stdio.h>
2#include <stdlib.h>
3
4int main() {
5 char sentence[1000];
6
7 // creating file pointer to work with files
8 FILE *fptr;
9
10 // opening file in writing mode
11 fptr = fopen("program.txt", "w");
12
13 // exiting program
14 if (fptr == NULL) {
15 printf("Error!");
16 exit(1);
17 }
18 printf("Enter a sentence:\n");
19 fgets(sentence, sizeof(sentence), stdin);
20 fprintf(fptr, "%s", sentence);
21 fclose(fptr);
22 return 0;
23}
24