#include
int main(int argc, char* argv[]){
FILE* fp;
char ch;
if(argc!=2){
printf("you forgot to enter the filenname.\n");
exit(1);
}
if((fp=fopen(argv[1],"w"))==NULL){
printf("cannot open file.\n");
exit(1);
}
do{
ch=getchar();
putc(ch,fp);
}while(ch!='$');
fclose(fp);
return 0;
}
After you compile it, you can run it on command prompt. And you can type in anything except you enter "$" and press enter key.