#include <stdio.h>
int main(void)
{
char ch;
FILE *p;
//opening file to write on it
p = fopen("text.txt", "w+");
printf("enter the sentence : ");
while ((ch = getchar()) != '\n') //user can type until they press enter
{
fputc(ch, p);
}
fclose(p);
//opening file in read mode to read its content
printf("content of file : ");
p = fopen("text.txt", "r");
while (!feof(p))
{
ch = fgetc(p);
printf("%c", ch);
}
fclose(p);
}
0 comments:
Post a Comment