Please look at my code and in case of indentation issues check the screenshots.
---------------main.c----------------
#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch;
printf("Enter a character: ");
scanf("%c", &ch);
//read the
character from user
FILE *outfile = fopen("output.txt", "w") ; //open
file for writing
fprintf(outfile, "%c", ch);
//write the character into file
printf("The character was written to output.txt
successfully\n");
return 0;
}
--------------Screenshots--------------------
------------------Output------------------
---------------------------------------------------------------------------------------------------------
Please give a thumbs up if you find this answer helpful.
If it doesn't help, please comment before giving a thumbs
down.
Please Do comment if you need any clarification.
I will surely help you.
Get Answers For Free
Most questions answered within 1 hours.