WWW.DISSERS.RU


...
    !

Pages:     | 1 |   ...   | 14 | 15 || 17 | 18 |   ...   | 21 |

oop e oo yx ao paee eoo ca o oy apecy. Ec popac eae o aoy apecy oec eoe aee, o o oe ca oaoc o ee peyeo oo a.

Haaoe aee apeca x oe e cooecoa oycoy apecy apecy, o oopoy eaeo paec eoe co. oee oo, aa apec, coepac x, oe, ecac, coaa c apeco a oca ao pyo ao ac oepaoo cce DOS. oa aca eoe o aoy apecy oe pec oy, o ye aepa ac oepaoo cce. coae, oop c Typo C o pyo oop c C e coy "oo" oy aoo poa.

Oeceoc a aa yaaee ooc e a popace.

cpa ay cya oo, cooa oy y pacpeee a malloc, ocao alloc, c oo oopo oo apoc a y, eoo 2 aa.

Oepaop, o yaae ec x=(int *) malloc(sizeof (int));

oe ocae eocpeceo epe oepaopo *x=16;

B popay ae ceye oca c oo include a alloc.h, coepa ocae y aecoo pacpeee a.

B aece apyea y aecoo pacpeee a malloc aaec co a, oope ceye apeeppoa ye. y cea opaae yaae a void, ooy ao yaae coec c yaaee, oop oe cpec eo ac oepaopa pcaa. ocoy ae cyae xo, o y malloc aa a apec eoo (epy aece peyaa yaae a eoe), ocoyec peopaoae (int *) epeoa ae, aaeoo ye malloc, apec, eceo yaa a eoe.

cooae y malloc peceye e e. Bo-epx, epeeo_yaae x pcaaec aee apeca, oopoe apapoao e coaae c apeca, coye cceo. Bo-opx, a, oeeo y, ec a aa, oopx oo paec eoe, oye apec aocc x.

Ec a o yy e coooo eca paee yx ao, o aece peyaa y malloc ye a apec 0.

Bo ox cyax ooae oe poep, e aa y aece peya 0. ooy yoo cooa oepaop malloc ceye ope:

If (( x=(int *) malloc( sizeof(int))) !=0) { /* pae popa*/ } Cya, oaa p cooa oepa malloc.

x apec a POEM, CBAHHE C AATEM X PAPEEHE Ocae epeeo_yaae ee ao y, a, apep, main, e po aa yaae, peeppoa ye a ae.

Cyecy epe cocoa aa epeeo_yaae occeoe aaoe aee:

1. Oca yaae e o y ca eo pecae static. Haa aee ec yeo apec a 0. epe e, a aa ooac yaaee, ceye apeeppoa a o aee.

2. pco yaae apec epeeo.

3. pco yaae aee pyoo yaae, oy oey ye pao apoaoy.

4. cooa y pacpeee a, ae, a alloc malloc.

ep coco ocoaec a ao coce caecx epeex. Bce caece epeee apyc aee 0.

ocoy oop oo a o epeey oe ee oca, o pcaae yaae apeca epeeo apapye, o ya a oeea. oce c cc aee yaae coaae co aee epeeo, apec oopo pcoe yaae.

oa yaae pcaaec aee pyoo yaae, o o oaae, o ooy oy e apecy a pcaac pae ea (eaop oex epeex_yaaee).

Ec aee, a oopoe ccac a yaae, ye eeo oepaope pcaa c cooae ooo yaaee, o aee, oyaeoe c oo pyoo yaae, ae ye eeo. Paccopea cya aaec o yaaee oe pec cepe poea.

Cepea oacoc oae, ec y opaae yaae, c apeco aoaeco (oao) epeeo. Aoaeca epeea ocaec yp y. a o ee ooc oe aa oa y. p xoe y a cex aoaecx epeex ocooaec. ooy opae apec oe oe cooa cceo, opa, coepaac o oy apecy, oe oaac aeeo oo opae. Bxo ocaoo ooe oa e opaa apeca aoaecx epeex.

Ee o co oo eocooee a, apoeo paee c oo y alloc malloc, oa yaae ye oe e ye. Ccea e cocoa aoaec ocooa a ye.

Bopa (ocooee) a ye oe y free. B aece apyea y free aaec yaae, ccac a ocooaey a.

ee oa oa pcaae epeeo_yaae apecoo ae eocpeceo.

a c c a C AA EPEMEHHA H, OCAHHA B POPAMME HA TPO C, PHAET AOM-O ACC AMT. ACC AMT EPEMEHO OPEEET BPEM EE CECTBOBAH OACT BMOCT.

acc a epeeo aaec o o pacooe ee oca, o p oo ceaoo ceaopa acca a, oeaeoo epe o ocae. acc a y cea external, ec oo epe ocae y e co ceaop static.

Bce epeee Typo C oo oec ooy ceyx acco a:

- automatic (aoaeca, oaa);

- register (pecpoa);

- extern (e);

- static (caeca).

A o a e c e e p e e e Aoaece epeee oo oca o, coy ceaop acca a auto. Ho ao coco oca peec peo. Oo yaae a o, o epeea ec aoaeco, aaec eo ceye ooe popae o oca ao epeeo.

o yoa paec, o ca epeea, ocaa yp y yp oa, opaeoo yp coa, e ea oo yaa a acc a, oocc accy a aoaecx epeex.

oe oc aoaeco epeeo aaec o o ee oca aaaec oe oa, oopo epeea ocaa. ocy a epee eeo oa eooe.

a aoaecx epeex ooc aec o pe oe popa p xoe o, oopo ocaa cooecya epeea. p xoe oa a, oeea o ce eo aoaece epeee, aoaec ocooaec. ocy aoaeco epeeo ooe oo oa, e epeea ocaa, a a o oea xoa o epeea ooe e cyecye (.e. o ee e oeea a).

Cape aoaece epeee p x oca e oyc. ooae oe ca yaa aaoe aee epeex oe x oca.

Pe c p o e e p e e e Ceaop a register oe cooac oo aoaecx epeex opax apaepo y.

Tao ceaop yaae oopy a o, o ooae eae paec epeey e oepao a, a a oo cpoecyx pecpo oepa. oop e oa o aoe peoae. Ha oce oepo eec oo eooe co pecpo, cocox yoeop eae ooae.

Ceaop register peoeyec cooa epeex, ocy oop y oec aco. oye peyae o ye oc cpee cae oee oa.

Cyecye opaee: e opaac apecy ax epeex. Pecpo epee oy oe oo aoaece epeee a short int, a ae e yaae.

BH E H E E PE ME HH E H a epeea, ocaa ae e ao-o y e ea ceaopa a, o yoa oocc accy a ex epeex. Tae epeee aac oa.

oax epeex oac oc pocpaec o o x oca o oa aa, e o oca. Ec yp oa ocaa aoaeca epeea, oopo coaae c ee oao epeeo, o yp oa oaa epeea acpyec oao. o oaae, o yp aoo oaoo oa ye a eo aoaeca epeea.

ex epeex a ooc o pa ocaec ao o ooa oe popa.

Ec ooae e yae apyee aee oa epee, o ye pcoeo aaoe aee 0.

Cpyype e epeee acc, cpyyp oee oy apoac ooaee oe x oca.

Bee epeee apyy, ocyecey copy oeo popa oeca oex ao. aoap oy e epee ooe ocy pyx ao. oo, o epeey oo o cooa pyo ae, ee ceye yaa ceaop a extern.

puep paeeo o ocae extern /* a separate.c */ int a=6;

/* a test.c */ #include main () { extern int a;

printf ("a = %d\n", a);

} Baae opyec a seperete.c. ae opyec a test.c, eo oe oy oeec c oe oye separate.c. Ec ooae aye p apye o a separate.c, o apy ac cooee o oe: eopeee co oye test.c.

Ocae extern int a; oaae oopy, o epeea a a int ocaa o ee pacpeeea a e aoo aa. Taa epeea oe cooaa a, a ec oa a ocaa ao ae.

Ec ocae extern epeeo pacooeo yp y, o eo ece pacpocpaec a ay y. Ec ocae extern axoc e y, o eo ece pacpocpaec o o oca o oa aa.

Ta opao, coeae ex epeex y oo ae ocae extern pyx aax ooe oe o oe a ecoo eaco copoax popa.

Peoeyec aoo aa peaa popa (aa c pacpee.c), ec x coyc ee oe, ocy oop ye ocyecc pyx ao, coaa epece a c pacpee.h oea ya ocae ex epeex. Toa oecee ocya e epee ao-opeee opeyec a cooecy epec a.

o yoa caec, o ce y ee. Meco opeee y ec a oa popa, e aac apaep y acaec ee eo. o ce y, e e ceaopa acca a static, opaee pyx ao oaaec oo, ec a y ocaec a e. Ta opao, y opeeec o pa, o oe ocaa oo pa (c cooae ceaopa extern).

C a e c e e p e e e y ypa y epeex o apya coyec ceaop a static. y epeee, oopx yaa ao acc a, o o oca o oa aa.

Ec ooae e yaa apyee aee, o ce caece epeee, a ee, apyc aee 0.

EC CTATECA EPEMEHHA OCAHA BHTP H, TO OHA EPB PA HAPETC P BXOE BO H. HAEHE EPEMEHHO COXPAHETC OT OHOO BOBA HO POO. TAM OPAOM, CTATECE EPEMEHHE MOHO COOBAT XPAHEH HAEH BHTP H HA POTEH BPEMEH PAOT POPAMM, PEM TAE EPEMEHHE T HEBM BHE AA, E OH OPEEEH.

Mo y a c a p aca ooyoax, oex popa eoxoo e oe o oyx.

B acae ooe ocy ooy cy cpoex oca, o ax, epeex, poeyp y. Heoope ce aca, pye IBM PC coecx c PC DOS.

oeco pax popa eo, o o oa o ce cpay popaax e coyc. Bce popa paee a cae ey coo py, aaee oy, oope oo cooa cyae eoxooc.

Moy o aop oca, o ax, epeex, poeyp y. a oy aaoe oeo popae. O ee: aoe eo, oopoe aec epe capo popa poo eoxoe ec o aa, oa o eoxoo. Moy o oea oe, oopy oo ca cooa yp popa, o ooe pae popay a ac opoa x oeo.

Oe yp oy ca py c pyo. Hapep, oy Crt coep ce oe popa pao c pao PC. aca peocae oce caapx oye. ec x System, Overlay, Graph, DOS, Crt, Printer ocyec oepy popa a Turbo Pascal; ce o coxpae TURBO.TPL.

e pye Turbo3 Craph3 ocyec oepy coecoc popa, acax epc 3.0. Turbo Vision peocae e aop oye.

C a a p e o y a TURBO.TPL coep ce caape oy, poe Graph oye coecoc (Graph3 Turbo3):

System, Overlay, Crt, Dos Printer. oy apyac a ece c aca; o cea ocy o popa. a TURBO.TPL xpac o e peop, o TURBO.EXE ( TPC.EXE).

Mo y S y s t e m Moy System oo e yaa peoe Uses, a a o aoaec pcoeec ao popae. Cy oep ooo oeca poeyp y, ax a o-o, paoa c aa ..

Mo y D o s Dos opeee oocee poeyp y aca, oope ae aoee aco coye oa Dos, a a GetTime, SetTime, DiskSize .. poe oo, ec opeec e popa oo ypo MsDos Intr, oope oo cooa o o MS-DOS ccee pepa.

Pages:     | 1 |   ...   | 14 | 15 || 17 | 18 |   ...   | 21 |



2011 www.dissers.ru -

, .
, , , , 1-2 .