.


:




:

































 

 

 

 


ұ ұ. ұ




қ ә ғ ұ ү . қ ә ғ қғ FILE . ұ ң қ stdio.h ққ қ қ. FILE қ ә ғ ұқ, ұқ ө .

қ ә ғ ұқ, , fp :

#include <stdio.h>

FILE *fp;

1) fopen() ң :

fp = fopen (name,mode);, fp = fopen(ex1.txt, w);

ұғ: fp ғ ұқ; name қ ә ғ , ; mode ң қ ө ү ө:

"r" ұ қ ү ;

"w" ә ү ;

"a" ң ә қ ү ;

"r+" ә қ ә ү ;

"w+" ә қ ә ғ ә ү (ұ , ө);

"a+" ә қ ә ң ң ә қ ү ).

2)fclose(fp) қ .

3)feof(fp) ң қ.

4)fgets(fp) қ.

5)fputc(fp) ғ .

6)ferror(fp) ғ /қ қ ққ .

ұғ fp ғ ұқ;

7-8) ғ ә /қ ү fprintf әfscanf .

fprintf - ғ ә ү, fscanf ә қ ү қ. ң ү:

fprintf(fp, , p); (: fprintf(fp,%d, p))

p - ө;

fscanf(fp, , ); (: fscanf(fp,%d, &p))

M:

#include<stdio.h>

#include<conio.h>

main()

{int k, i, n=5;

char fname[]=a:\\num.txt\0;

clrscr();

FILE *fp;

fp=fopen(fname,w);

clrscr();

printf(" %s \n", fname);

puts(Ә ң Enter ң/n);

for(i=0; i<n; i++)

{ scanf(%i, &k);

Fprintf(fp, %d, k); }

fclose(fp);

printf(" %s \n", fname);

getch(); }

ә:

a:\num.txt

Ә ң Enter ң

a:\num.txt

 

 


әң қ құ. әң қ .

( ) .

, . , . . :

, , ; - , , ..;

, , ;

() , , . . , , . .

.

struct , date :

#include <stdio.h>

struct date {

int month; //

int day; //

int year; //

void set_date(int d, int m, int y) {

day = d; month = m; year = y; }

void print_date(void);

};

void date::print_date(void) {

printf("%d.%d.%d",day, month, year);

}

int main() {

date today;

today.set_date(2, 4, 2014);

today.print_date();

getchar();

return 0;

}





:


: 2015-10-01; !; : 1071 |


:

:

. .
==> ...

1626 - | 1561 -


© 2015-2024 lektsii.org - -

: 0.014 .