( Standardne biblioteke C jezika )


Uz programski jezik C se isporučuju standardne biblioteke rutina. Biblioteke sadrže procedure, funkcije i promenljive. Rutine iz biblioteka se uključuju u program ključnom reči:    #include <biblioteka.h>

Prva biblioteka koju smo upoznali: stdio.h    sadrži rutine i promenljive vezane za ulazno-izlazne poslove.  Ostale biblioteke su:

  • math.h – matematičke funkcije
  • stdlib.h – korisničke funkcije, konverzije, smeštanje podataka itd.
  • string.h – biblioteka za rad sa stringovima
  • ctype.h – biblioteka za testiranje i konverziju karaktera
  • time.h – biblioteka za rad sa datumom i vremenom

Postoje i biblioteke koje su specifične za OS - njh zasad nećemo spominjati:

( za rad sa konzolom, za pristup rutinama BIOS-a, za rad sa funkcijama DOS-a, za rad sa funkcijama Windows-a )

Stdio.h   funkcije:

  • fopen/fclose – otvaranje/zatvaranje datoteke
  • fprintf/fscanf – štampanje/čitanje iz datoteke
  • printf/scanf – štampanje/čitanje iz standardnog ulaza/izlaza (tastatura/ekran)
  • putc/getc – štampanje/učitavanje jednog znaka iz standardnog ulaza/izlaza
  • puts/gets – štampanje/učitavanje stringa iz standardnog ulaza/izlaza
  • fread/fwrite – učitavanje/snimanje bloka bajtova iz datoteke

Math.h   funkcije:

  • sin, cos, tan
  • asin, acos, atan
  • sinh, cosh, tanh
  • exp(x) - ex
  • log(x) - ln(x)
  • log10(x) - log(x)
  • pow(x, y) - xy
  • sqrt – kvadratni koren
  • ceil – zaokružuje na gore
  • floor – zaokružuje na dole

Stdlib.h     funkcije:

  • atof – konverzija stringa u float
  • atoi – konverzija stringa u int
  • atol – konverzija stringa u long
  • rand, random – pseudoslučajni broj
  • malloc/free – alokacija/oslobađanje memorije
  • exit – završetak rada programa
  • system – izvršava program
  • abs – apsolutna vrednost
  • qsort – QUICK SORT
  • div – celobrojno deljenje

String.h    funkcije:

  • strcpy – kopira polazni string u odredišni
  • strncpy – kopira polaznih n slova u odredišni string
  • strcat – spaja drugi string na kraj prvog
  • strncat – spaja najviše n slova drugog stringa na kraj prvog
  • strcmp – poredi stringove
  • strncmp – poredi najviše n slova prvog stringa sa drugim
  • strchr – vraća pokazivač na prvo mesto zadatog slova u stringu
  • strstr – vraća pokazivač na prvu pojavu zadatog stringa u prvom stringu
  • strlen – vraća dužinu stringa

Ctype.h   funkcije:

  • isalpha – da li je slovo
  • isdigit – da li je broj
  • isalnum – da li je alfanumerik (slovo ili broj)
  • iscntrl – da li je kontrolni znak
  • islower/isupper – da li je malo/veliko slovo
  • isxdigit – da li je heksadecimalna cifra

Time.h    funkcije:

  • time – vraća trenutno kalendarsko vreme
  • difftime – vraća razliku dva vremena u sekundama
  • strftime – pravi formatiranu tekstualnu reprezentaciju vremena i datuma

***************************************************************************************

Ako dovoljno razumete engleski, u nastavku je data lista često korišćenih standardnih funkcija iz biblioteke math.h. Ako kliknete na naziv funkcije - moći ćete da vidite i primen korišćenja:

Function
Description
floor egg This function returns the nearest integer which is less than or equal to the argument passed to this function.
round egg This function returns the nearest integer value of the float/double/long double argument passed to this function. If decimal value is from “.1 to .5”, it returns integer value less than the argument. If decimal value is from “.6 to .9”, it returns the integer value greater than the argument.
ceil egg This function returns nearest integer value which is greater than or equal to the argument passed to this function.
sin egg This function is used to calculate sine value.
cos egg This function is used to calculate cosine.
cosh egg This function is used to calculate hyperbolic cosine.
exp egg This function is used to calculate the exponential “e” to the xth power.
tan egg This function is used to calculate tangent.
tanh egg This function is used to calculate hyperbolic tangent.
sinh egg This function is used to calculate hyperbolic sine.
log egg This function is used to calculates natural logarithm.
log10 egg This function is used to calculates base 10 logarithm.
sqrt egg This function is used to find square root of the argument passed to this function.
pow egg This is used to find the power of the given number.
trunc.(.) This function truncates the decimal value from floating point value and returns integer value.
****************************************************************************************

Nakon ovoga - neke od funkcija u stdlib.h:


Last modified: Sunday, 7 April 2019, 2:32 PM