Funzioni di libreria

Introductio

Generallyreferstothefunctionsprovidedbythecompilerthatcanbecalledinthecsourceprogram.Canbedividedintotwocategories,oneisthelibraryfunctionspecifiedbytheClanguagestandard,andtheotheristhelibraryfunctionspecifictothecompiler.

Duetocopyrightreasons,thesourcecodeoflibraryfunctionsisgenerallyinvisible,butyoucanseetheintroductionofitsexternalinterfacelibraryfunctionsintheheaderfile.

TheClanguagestatementisverysimple.IfyouwanttousetheClanguagestatementtodirectlycalculatethesinorcosfunction,youneedtowritearathercomplicatedprogram.BecausetheClanguagestatementdoesnotprovideastatementthatdirectlycalculatesthesinorcosfunction.Anotherexampleistodisplayaparagraphoftext,wecannotfindthedisplaystatementintheClanguage,wecanonlyusethelibraryfunctionprintf.

ThelibraryfunctionsoftheClanguagearenotpartoftheClanguageitself.Itisasetofprogramscompiledandprovidedbythecompileraccordingtotheneedsofgeneralusers.TheClibraryfunctionsgreatlyfacilitateusers,andatthesametimesupplementthedeficienciesoftheClanguageitself.Infact,whenwritingClanguageprograms,libraryfunctionsshouldbeusedasmuchaspossible,sothatboththeefficiencyoftheprogramandthequalityofprogrammingcanbeimproved.

Thestaticlibraryis calledhere.

Basicconcepts

Functionlibrary:Thefunctionlibraryisacollectionoffunctionswithcertainfunctionsestablishedbythesystem.Thenameofthefunctionandthecorrespondingobjectcodearestoredinthelibrary,aswellastherelocationinformationrequiredduringtheconnectionprocess.Userscanalsobuildtheirownuserfunctionlibraryaccordingtotheirneeds.

Libraryfunctions:functionsstoredinthefunctionlibrary.Libraryfunctionshaveclearfunctions,entrycallparametersandreturnvalues.

Linkprogram:Linktheobjectfilesgeneratedbythecompilertogenerateanexecutablefile.

Headerfiles:Sometimescalledincludefiles.ThedataandvariablestobeusedforinformationcommunicationbetweentheClanguagelibraryfunctionandtheuserprogram.Whenusingalibraryfunction,theheaderfilecorrespondingtothefunctionmustbeembedded(using#include)intheprogram.

BecausethereisnointernationalstandardforthefunctionlibrarythattheClanguagecompilationsystemshouldprovide.DifferentversionsoftheClanguagehavedifferentlibraryfunctions,andusersshouldrefertothelibraryfunctionreferencemanualoftherelevantversionofCwhenusingit.Let'stakeTurboC?asanexampletointroducethelibraryfunctionsofC,andsomecommonlyusedlibraryfunctionsofTurboCaregivenintheappendix.

Ninecategories

(1)I/Ofunctions.IncludingvariousconsoleI/O,bufferedfileI/OandUNIX-styleunbufferedfileI/Ooperations.

Requiredincludefile: stdio.h

Forexample:getchar,putchar, printf,scanf,fopen,fclose,fgetc,fgets,fprintf,fsacnf,fputc,fputs,fseek,fread,fwrite,etc.

(2)String,memoryandcharacterfunctions.Includingfunctionsforperformingvariousoperationsonstringsandperformingoperationsoncharacters.

Requiredincludefiles:string.h,mem.h,ctype.h,orstring.h

Praenomen: functiones for checkingcharacteres: isalnum, isalpha, isdigit, is inferior, isspace, etc. ?Functiones forstringmanipulation: strcat, strchr, strcmp, strcpy, strlen, strstr, etc.

(3)Mathematicalfunctions.Includingvariouscommonlyusedtrigonometricfunctions,hyperbolicfunctions,exponentialandlogarithmicfunctions,etc.

Needincludefile: math.h

Forexample: peccatum, cos, exp(etothepowerofx), stipes, sqrt(quadrata), pow(xofyPower)et mox.

(4) Tempus, date and systema-related functiones. Operatio temporis et temporis et occasus computatorum systematis, etc.

Requiredincludefile: time.h

Forexample:timereturnsthetimeofthesystem;asctimereturnsthedateandtimeintheformofastring.

(5) Dynamicstorageallocation.Including thefunctions of "applicationforallocation" and "release" ofmemoryspace.

Requiredincludefiles: alloc.horstdlib.h

Praenomen: callocum, liberum, malloc, realloc, etc.

VI.

(7) Processcontrol.Includingthemostbasicprocesscontrolfunctions.

(8) Characterscreenandgraphicfunctions.

(9) Alia.

Content

Thefunctionofthefunctionandtheoperationsitcancomplete

②Thenumberandorderoftheparameters,aswellasthemeaningandtypeofeachparameter

Themeaingandtypeofthereturnvalue

Theincludefilethatneedstobeused

Thisisanecessaryconditionforthecorrectuseoflibraryfunctions.

Relateddifferences

(1)Libraryfunctionsarepartofthelanguageorapplicationprogram,whilesystemcallsaretheinterfaceprovidedbythekerneltotheapplicationprogram,andarepartofthesystem

(2)Libraryfunctionsareexecutedintheuseraddressspace,systemcallsareexecutedinthekerneladdressspace,libraryfunctionrunningtimebelongstousertime,systemcallsbelongtosystemtime,libraryfunctionoverheadissmall,andsystemcalloverheadislarge

(3)Libraryfunctionsarebuffered,systemcallsareunbuffered

(4)Systemcallsdependontheplatform,libraryfunctionsdonotdependon

inaedificata infunctionsLibrary

1.TherelationshipbetweenClanguageandClanguagelibraryfunctionsissimilartotherelationshipbetweenChinesecharactersandclassicworks.Clanguageisacomputerprogramminglanguage,andClanguagefunctionlibraryisadocumentwritteninClanguage.ItisconvenientforlatecomerstousetheClanguagemoresimplyandquickly.

2,Clanguageisanintroductorylanguageforprogramming.SincetheClanguagestatementdoesnotprovideastatementtodirectlycalculatethesinorcosfunction,itwillcausedifficultyinwritingtheprogram;butthefunctionlibraryprovidesthesinandcosfunctions,whichcanbeusedtodirectlycall.Todisplayaparagraphoftext,wecan'tfindthedisplaystatementinClanguage,wecanonlyusethelibraryfunctionprintf.ThelibraryfunctionofClanguageisnotapartofClanguageitself,itisasetofprogramscompiledandprovidedbythecompileraccordingtotheneedsofgeneralusers.TheClibraryfunctionsgreatlyfacilitateusers,andatthesametimesupplementthedeficienciesoftheClanguageitself.WhenwritingaClanguageprogram,usinglibraryfunctionscannotonlyimprovetheoperatingefficiencyoftheprogram,butalsoimprovethequalityofprogramming.

Related Articles
TOP