.


:




:

































 

 

 

 





1.1, / FILE, , , Windows HANDLE, 1.2.

1.1. C:

/* 1. cp. , . */

/* cp 1 2: 1 2. */

#include <stdio.h>

#include <errno.h>

#define BUF_SIZE 256

 

int main(int argc, char *argv[]) {

FILE *in_file, *out_file;

char rec [BUF_SIZE];

size_t bytes_in, bytes_out;

if (argc!= 3) {

printf(": 1 2\n");

return 1;

}

in_file = fopen(argv [1], "rb");

if (in_file == NULL) {

perror(argv[1]);

return 2;

}

out_file = fopen(argv [2], "wb");

if (out_file == NULL) {

perror(argv [2]);

return 3;

}

/* . */

while ((bytes_in = fread(rec, 1, BUF_SIZE, in_file)) > 0) {

bytes_out = fwrite(rec, 1, bytes_in, out_file);

if (bytes_out!= bytes_in) {

perror(" .");

return 4;

}

}

fclose (in_file);

fclose (out_file);

return 0;

}

, Windows.

1. FILE ( UNIX ). NULL . , .

2. fopen , . , , , . , Windows, / , , . .

3. perror, , , , fopen, errno. ferror, , , FILE.

4. fread fwrite , , . , .

5. fclose FILE ( UNIX).

6. / , , /.

7. / printf, Windows-.

, , UNIX, Windows, , ANSI . , , , , , / , . , /, Windows ( 7).

UNIX, , , , ( fseek , , fsetpos fgetpos), / , . , Visual C++ , , , . , .

, , / , , , Windows, .





:


: 2015-09-20; !; : 605 |


:

:

.
==> ...

1359 - | 1199 -


© 2015-2024 lektsii.org - -

: 0.012 .