- #include <stdio.h>
- #include <io.h>
- #include <fcntl.h>
- void main(void)
- {
- int handle;
- char buffer[512];
- int bytes_read;
- if ((handle = open("\CONFIG.SYS", O_RDONLY)) == -1)
- printf("Error opening \CONFIG.SYSn");
- else
- {
- printf("Current file position %ldn", tell(handle));
- while (bytes_read = read(handle, buffer, sizeof(buffer)))
- write(1, buffer, bytes_read);
- printf("Current file position %ldn", tell(handle));
- close(handle);
- }
- }