#include<stdio.h>
#include<conio.h>
main()
{
    FILE *fp;
    char ch;
    if((fp=fopen("d:\\good.txt","wt"))==NULL)
    {
        printf("open failed\n");
        exit(0);
    }
    ch=getchar();
    while (ch!='\n')
    {
        fputc(ch,fp);
        ch=getchar();
    }
    fclose(fp);
    printf("do you want to preview your messeage y or n\n");
    ch=getchar();
    if(ch=='y'||ch=='Y')
    {
        fopen("d:\\good.txt","rt");
    ch=fgetc(fp);
    while (ch!=EOF)
    {
        putchar(ch);
        ch=fgetc(fp);
    }}
    else
    exit(0);
    printf("\n");
    fclose(fp);
    getch();
    fopen("d:\\good.txt","w");
    getch();
    fclose(fp);exit(0);
}