#include <stdio.h>
int main()
{
FILE *fp;
char ch;
if((fp=fopen("c:\\test.txt","w"))==NULL)
{
printf("Can open the file!");
exit(0);
}
ch=getchar();
while(ch!='!')
{
fputc(ch,fp);
ch=getchar();
}
fclose(fp);
return 0;
}
#include <stdio.h>
int main()
{
FILE *fp;
char str[100];
if((fp=fopen("c:\\text1.txt","w"))==NULL)
{
printf("Errors!\n");
exit(0);
}
gets(str);
fputs(str,fp);
fclose(fp);
return 0;
}