#include <stdio.h>
int main(void)
{
char ch;
FILE *p;
//-----------------
//write a character in file
p = fopen("text.txt", "w");
printf("Enter a character to write on file ");
ch = getchar();
fputc(ch, p);
fclose(p);
//view the character in file
p = fopen("text.txt", "r");
ch = fgetc(p);
printf("A character in file is %c", ch);
fclose(p);
}
0 comments:
Post a Comment