#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
void main()
{
FILE *fp;
char ch,fname[10];
printf("Enter filename:");
scanf("%s",fname);
if((fp=fopen(fname,"w"))==NULL)
{
printf("cannot open file\n");
exit(0);
}
printf("Enter content and end with #\n");
ch=getchar();
while(ch!='#')
{
fputc(ch,fp);
ch=getchar();
}
fputc(ch,fp);
printf("write file over\n");
printf("**********************");
fclose(fp);
if((fp=fopen(fname,"r"))==NULL)
{
printf("cannot open file\n");
exit(0);
}
printf("\nthis filecontent is :\n");
ch=fgetc(fp);
while(ch!='#')
{
putchar(ch);
ch=fgetc(fp);
}
putchar(ch);
printf("\nfile is over \n");
fclose(fp);
}