WWW.DISSERS.RU


...
    !

Pages:     | 1 |   ...   | 9 | 10 || 12 | 13 |   ...   | 21 |

RESET (FILE1); {OTPTE AA TEST1.DAT POBEP PABHOCT AC} while not eof (File1) do {ee aa o ex op, oa yaae} {eye ooe aa axoc epe} {ocee ooeo aa} begin Read (File1, a[i]); {Cae ce aa} Write (a[i]:2); {Paceaa caex ce} If a[i]>0 then pol:=pol+1; {oce ca ooex, opaex} if a[i]<0 then otr:=otr+1; { yex eeo} if a[i]=0 then nul:=nul+1;

Inc (i); { ppaee cea a } end;

WriteLn; { poyc cpo } WriteLn ('');

Write (File2, pol); { ac ca ooex, opaex } Write (File2, otr); { yex eeo a Test2.dat } Write (File2, nul);

Close (File2); { ape ao Test1.dat Test2.dat } Close (File1);

Assign (File2, Road2); { Ope aa Test2.dat } Reset (File2); { poep paoc ac ea peyao} Read (File2, pol); WriteLn ('oeco ooex: ', pol:3);

Read (File2, otr); WriteLn ('oeco opaex:', otr:3);

Read (File2, nul); WriteLn ('oeco yex:', nul:3);

Close (File2); { ape aa Test2.dat } ReadKey; { aepa paa } end.

aee paccop ecoe a.

Te c oe a B o paee ocac oepa oa/oa, coye aoy epeey caapoo a Text.

ae, o Turbo Pascal Text oaec o a file of char.

p op ecooo aa e a eppepyec oco opao: caec, o o pecae coo oceoaeoc coo, cpypoax cpo, e aa cpoa aaaec coo oa cpo (end of line), oop pecae coo co epeoa ape, a oop, ooo, ceye co epeoa cpo.

ecox ao cyecye cea oepa e ac (Read Write), oope oo ca aca ae, oopx oaec o a Char. Tae ae aoaec epeoc cooe pecaee opao. Hapep, Read (F, i), e i epeea eoo a, pee ca oceoaeoc p, eppea o oceoaeoc, a ecoo ca, coxpae eo i.

a o oeeo paee, ec e caape epeee ecooo a Input Output. Caapa aoa epeea Input o ocy oo e a, ca co caap ao oa oepaoo cce (oo o aaypa), a caapa aoa epeea Output o ocy oo ac a, ca co caap ao oa oepaoo cce (oo o ce). epe aao oe popa a Input Output aoaec opac, a ec oe ceye oepaop :

Assign (Input, ''); Reset (Input);

Assign (Output, ''); Rewrite (Output);

Aaoo, oce oe popa a aoaec apac.

Ec popaa coye caap oy Crt, o a Input Output e yy o yoa oocc caap aa oa/oa.

eoopx caapx poeyp, cco oopx pee ao paee, e peyec o yaa aece apaepa aoy epeey. Ec o apaep oye, o o yoa yy paccapac Input Output, acoc o oo, ye poeypa y opepoaa a o o. Hanpuep:

Read (X) cooecye Read (Input, X) Write (X) cooecye Write (Output, X).

Ec p oe oo poeyp y oo paea aaec a, o o oe ca c e ao c oo poeyp Assign op c oo poeyp Reset, Rewrite, Append. Ec opepoao a o poeyp y yaa a a, oop op c oo poeyp Reset, o eec cooee o oe.

Aaoo, ye oo aaa opepoao a o poeyp y a, op c oo poeyp Rewrite Append (a. 19, 20).

1 9 P O E P Haeoae Haaee Append Opae cyecy a oae Flush Baae yep aa oa Cae oo oee ae ecooo aa Read oy oee epeex Boe e e ec, o Read, a oo eae Readln poyc o aaa ceye cpo aa SetTextBuf Haaae yep oa/oa ecooo aa Write acae eco a oo oee ae Boe e e ec, o Write, a ae oae Writeln ay apep oa cpo 2 0 H Haeoae Haaee Eoln Bopaae aa cocoe end-of-line (oe cpo) SeekEof Bopaae aa cocoe end-of-file (oe aa) SeekEoln Bopaae aa cocoe end-of-line (oe cpo) Read ([]; cco oa); ca opa ecooo c aayp.

Writeln ([], cco oa); oa opa eco a a ce.

He poa e a Hepoae a peca coo aa oa/oa eo ypo, coyee ocoo poo ocya oy ay a ce, eaco o eo a cpyyp.

o epoa a oec co coo file e apyo, anpuep:

var Datafile : file;

epoax ao poeypax Reset Rewrite oycaec yaa ooe apaep, o aa paep ac, coyc p epeae ax.

o yoa a ac paa 128 a. peoeo o ac ec a ac, paa 1, ocoy o eceoe aee, oopoe oo opaae paep oo aa (ec a ac paa 1, o eoe ac eoo). 512 ao paep ceopa eco e xpae opa a aox ocex.

a cee poeyp Read Write cex epoax ao oycaec cooae o caapo poeyp, oopy papeeo cooa c poa aa. Beco poeyp Read Write ec coyc cooeceo poeyp BlockRead BlockWrite, ooe epeca ae c coo copoc (a. 21).

puep paom:

Var InFile, OntFile: File;

Buffer: Array [1, , 512] of Byte;

Begin Assign (InFile, TlisFile); {a co ax} Assign (OutFile, TlisFile); {a p ax} Reset (InFile, 512);

Rewrite (OntFile, 512);

While not EOF (InFile) do{ opoa ax coa pe } Begin BlockRead (InFile, Buffer, 1);

BlockWrite (OntFile, Buffer, 1);

End;

Close (OntFile);

Erase (InFile); {yaee aacoa} End.

21 P O E P Haeoae Haaee BlockRead Cae epeey oy oee ace BlockWrite acae oy oee ace epeeo E P E M E H H A F I L E M O D E epeea FileMode, opeeea oye System, ycaaae o ocya, oop epeaec DOS, oa poae epoae a (o e ecoe) opac c oo poeyp Reset.

o yoa aaec aee FileMode paoe 2, oopoe papeae ee, ac. pcaae pyoo ae epeeo FileMode po oy, o ce oceye o poeyp Reset yy cooa o pe.

aao oox ae FileMode ac o coyeo epc DOS. Oao cex epc aac ceye pe :

0 : oo ee 1 : oo ac 2 : ee/ac Bepc 3.X DOS aae ooee pe, oope a opao ca c paee cooae ao cex. ( oye oee opoo opa, opaec pyoocy popaca o DOS).

peae: Hoe a, coae c oo poeyp Rewrite, cea opac pee Read/Write, cooecye ae epeeo FileMode = 2.

C T P O C T B A B oepaoo ccee DOS e aapaypa, a apep, aaypa, ycpoco ea, ce, paccapac, a ycpoca. Co pe popaca ycpoco oo paccapa a a c oo paoa c oo oo e aopa caapx y, o c ao. B Turbo Pascal oepaec a a ycpoc ycpoca DOS ycpoca ecox ao.

cpoca DOS cpoca DOS peaoa c oo apeeppoax e ycpoc, oope e cea cc.

cpoca DOS ooc popa : Turbo Pascal eeco ae, oa aoa epeea caa c ycpoco, a oa c ao a ce. Hanpuep, popaa:

var Lst : Text;

begin Assign (Lst, 'LPT1');

Rewrite (Lst);

Writeln (Lst, 'Hello World...');

Close (Lst);

end.

ee cpoy 'Hello World...' a ycpoco ea, xo cacc oo ao e, a ec oa oac a a ce.

cpoca, peaoae oepaoo ccee DOS, coyc oopeeoo oa oa acoc o aae.

CTPOCTBO CON cpoco CON oaae oco, ocpeco oopo oa opa epecaec a pa ce, a oa opa ocpaec c aayp. Ec e o eeo apaee oa oa, o caape a Input Output ce a, oop pcoeo ycoe , ccac a ycpoco CON.

Boa c ycpoca CON opa ec cpoo opepoao coye cpeca peapoa cpo, oope oca pyooce o DOS. Co cac yepa cpo, a oa yep caoc yc, oc oa cpoa. p aa a CTRL-Z eeppyec co oa aa (end-of-file), oce oopoo y eof ye opaa aee True.

CTPOCTBA LPT1, LPT2, LPTB aece oooo ocpooo ycpoca ea oycaec cooae pex ycpoc ea. Ec pcoeeo oo ycpoco ea, a eo oo ccac a a ycpoco LPT1. oo ycpoca oo ae cooa co PRN.

ocpooe ycpoco ea o ycpoco, peaaeoe oo oa. p o oe cooa poeypy Reset op aa, caoo c o x ycpoc, eeeo eeppyec pa oa aa.

peae: Caap oy Printer ocae ecoy aoy epeey c ee Lst ycaaae ee c c ycpoco LPT1. o oece o ao-o opa ae popa a ycpoco ea, e peoee uses coe popae oy Printer, a oa coye poeypy Write (Lst,...).

CTPOCTBA COM1 COMcpoca oyaooo opa c a oceoaex oyaox opa. Beco COMoo cooa co AUX.

CTPOCTBO NUL Hyeoe ycpoco oppye y ac a eo eeeo eeppye pa oa aa p oe ca c oo ycpoca. Eo ceye cooa, ec e xoe coaa oe a, a popae peyec yaa xooo xooo aa.

CTPO C p o C Ba oacco ooepx acco c acc coo, cpo.

Haoee a ao, oocc cpoa, ec o, o oca cpo aaac ye coo '\0'. Cpoa-ocaa (cpoa-epa) opaaec o aa. B oe ao cpo oop ocae pa oa cpo-epaa, co '\0'.

#include char message[50]="He said that he was busy";

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

y c aa p o o e pa o c o c poa C char *strcat (char *dest, char *source) oaepye cpo dest source.

char *strncat (char *dest, char *sours, unsigned maxlen) pcoee maxlen coo cpo source cpoe dest.

char *strchr (char *source, char ch) oc cpoe source epoo xoe coa ch.

int strcmp (char *s1, char s2) opaae 0, ec s1 = s2, opaae <0, ec s10, ec s1>s2. Int strcmp (char *s1, chat *s2, int maxlen). Cpaac oo epe maxlen coo yx cpo.

char *strcpy (char *dest, char *source) opoae cpo source cpoy dest.

char *strncpy (char *dest, char *source, unsigned maxlen) opoae maxlen coo cpo source cpoy dest.

int strlen (char *s) ae co coo cpoe s e yeoo coa oa cpo.

char *strlwr (char *s) epeo c cpoy s pecp ( cpoe y).

char *strupr (char *s) poce y char *strdup (char *s) ae y malloc oo eco o o s.

char *strset (char *s, char *ch) aoe c cpoy s coa ch.

char *strcspn (char *s1, char *s2) opaae y aaoo ceea cpo s1, oopa coco ceo coo, e coepaxc cpoe s2.

char *strpbrk (char *s1, char *s2) pocapae cpoy s1 o ex op, oa e e cpec co, coepac s2.

char *strrchr (char *s, char *c) pocapae cpoy s o oceeo oe e coa c.

char *strtok (char *s1, char *s2) peoaaec, o cpoa s1 coco paeo, paeex oo- ooco paee cpo s2. p epo opae strtok aec yaae a ep co epoo paea cpo s1. oceye o c aae y eco epoo paea yy aa apeca aex paeo cpo s1 o ex op, oa paeo e ocaec.

puep cooa cpoox y C:

#include #include #include int main(void) { char *b="tyrbo ", *a="c++", *c, *k="r";

char *d="IRINA";

inti;

clrscr();

c=strpbrk(b,"y"); // pocapae cpoy b o ex op, oa e e cpec //co'y'.

printf("1 strpbrk %s\n", c); a pae:1 strpbrk yrbo strtok(b,a);// peoaaec, o cpoa b coco paeo, paeex //oo- ooco paee cpo a.

printf("2 strtok %s\n", b); a pae: 2 strtok tyrbo strlwr(d);// epeo c cpoy d pecp ( cpoe y) printf("3 strlwr %s\n",d);a pae: 3 strlwr irina strupr(d);// poce y printf("4 strupr %s\n",d);a pae: 4 strupr IRINA c=strcat(b,a);// oee cpo a b printf("5 strcat %s\n", c);a pae: 5 strcat tyrbo c++ c=strchr(b,'y');// oc cpoe b epoo xoe coa y.

printf("6 strchr %s\n", c); a pae: 6 strchr yrbo c++ i=strcmp(a,b);// opaae 0, ec a==b, opaae <0, ec a0, ec a>b.

printf("7 strcmp %i\n", i); a pae: 7 strcmp -strcpy(b,a);// opoae cpo b cpoy a.

printf("%s\n", b);a pae: ++ getch();

Pages:     | 1 |   ...   | 9 | 10 || 12 | 13 |   ...   | 21 |



2011 www.dissers.ru -

, .
, , , , 1-2 .