C Program to Write a Sentence to a File | Program Clips

preview_player
Показать описание
#Cprogram
Source Code:
//Program to Write a Sentence to a File
#include stdio.h
#include stdlib.h
void main()
{
char sentence[1000];
// creating file pointer to work with files
FILE *fptr;
// opening file in writing mode
// exiting program
if (fptr == NULL) {
printf("Error!");
exit(1);
}
printf("Enter a sentence:\n");
fgets(sentence, sizeof(sentence), stdin);
fprintf(fptr, "%s", sentence);
fclose(fptr);
}
//Check a file named program in your folder
Рекомендации по теме