.


:




:

































 

 

 

 





, :

int fileno (FILE * f) (fd) f, .. , ;

long filelength (int fd) , fd, ;

int chsize (int fd, long pos) , fd, pos;

int feof (FILE * f) ;

int fgetpos (FILE * f, long * pos) pos f.

 

, , , . .

#include <stdio.h>

#include <stdlib.h>

struct Sved {

char Fam[30];

double S_Bal;

} zap,zapt;

char Spis[]="c:\\work\\Sp.dat";

FILE *F_zap;

FILE* Open_file(char*, char*);

void main (void)

{

int i, j, kodR, size = sizeof(Sved), kod_read;

while(1) {

puts(" 1\n 3\n 2\n 0");

scanf("%d",&kodR);

switch(kodR) {

case 1: case 3:

if(kodR==1) F_zap = Open_file (Spis,"w+");

else F_zap = Open_file (Spis,"a+");

while(2) {

puts("\n Fam (. end) ");

scanf("%s",zap.Fam);

if((zap.Fam[0])=='.') break;

puts("\n Ball: ");

scanf("%lf",&zap.S_Bal);

fwrite(&zap,size,1,F_zap);

}

fclose(F_zap);

break;

case 2: F_zap = Open_file (Spis,"r+"); int nom=1;

while(2) {

if(!fread(&zap,size, 1, F_zap)) break;

printf(" %2d: %20s %5.2lf\n",

nom++, zap.Fam, zap.S_Bal);

}

fclose(F_zap);

break;

case 0: return; // exit (0);

} // switch ()

} // while ()

}

//

FILE* Open_file(char *file, char *kod)

{

FILE *f;

if(!(f = fopen(file, kod))) {

puts("Open File Error!");

exit(1);

}

return f;

}

 

.

1. .

2. .

3. , , . () , , , .

4. (, ) . () ID , > () .

5. memcpy.

6. - .

7. , , .

8. , - , .

9. , .. .

10. ( fopen), ( fclose).

 

 

6.

 

, :

;

;

;

: , , , ;

.

, .

1. , 8, 9 10.

2. -, .

3. - .

4. , 9 10.

5. , 9 10 .

6. . , .

7. , 4 5 .

8. .

9. , .

10. , 3 4.

11. , 9 .

12. , 8 9 .

13. , .

14. - .

15. , .

 

, -

 

. : ( ), ().

7.

, , 6. . .

:

;

;

;

();

( 6).

.

. , ; Enter, . , .

:

a. txt;

;

;

.

:

1. , .

2. 11-, 12-, 13-,..., 10-.

3. .

4. .

5. , , .

6. , , .

7. .

8. .

9. , , , , .

10. .

11. .

12. , .

13. .

14. , , .

15. , , .





:


: 2016-11-12; !; : 1497 |


:

:

, .
==> ...

802 - | 695 -


© 2015-2024 lektsii.org - -

: 0.019 .