DOSCOPY.C
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
- #include <stdio.h>
- #include <dos.h>
- #include <fcntl.h>
- void main(int argc, char *argv[])
- {
- char buffer[1024];
- int input, output; /* file handles */
- unsigned bytes_read, bytes_written; /* actual number of bytes transferred */
- if (argc < 3)
- fprintf(stderr, "Must specify source and target filen");
- else if (_dos_open (argv[1], O_RDONLY, &input))
- fprintf(stderr, "Error opening source filen");
- else if (_dos_creat (argv[2], 0, &output))
- fprintf(stderr, "Error opening target filen");
- else
- {
- while (!_dos_read(input, buffer, sizeof(buffer), &bytes_read))
- {
- if (bytes_read == 0)
- break;
- _dos_write(output, buffer, bytes_read, &bytes_written);
- }
- _dos_close(input);
- _dos_close(output);
- }
- }