/*
从键盘输入一些字符,将他们逐个送到磁盘上去,直到输入一个'#'为止
*/
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
FILE *fp;
char ch,filename[10];
cout<<"请输入文件的名字:"<<endl;
gets(filename);
if((fp=fopen(filename,"w"))==NULL)
{
cout<<"打开文件失败:"<<endl;
return 0;
}
else
{
cout<<"请输入字符串到磁盘中:"<<endl;
ch=getchar();
while(ch!='#'){
fputc(ch,fp);
putchar(ch);
ch=getchar();
}
}
fclose(fp);
return 0;
}