home *** CD-ROM | disk | FTP | other *** search
- /* simple file copier with console echo */
- /* demonstrates fgetc() and fputc() */
-
- main()
- {
- FILE *fi, *fo;
- int c;
- char source[25], dest[25];
-
- printf("Input filename: ");
- gets(source);
- printf("Output filename: ");
- gets(dest);
- if((fi = fopen(source, "r")) == NULL) {
- printf("\tCan't open %s\n",source);
- exit();
- }
- if((fo = fopen(dest, "w")) == NULL) {
- printf("\tCan't open %s\n",dest);
- exit();
- }
- while((c = fgetc(fi)) != EOF) {
- putchar(c);
- fputc(c, fo);
- }
- fclose(fi);
- fclose(fo);
- puts("\n{DONE}");
- }