LIBRARY YANG SERING DIGUNAKAN PADA
BAHASA C
1. Library iostream.h
Standard
Input / Output Streams Library.
Elemen
iostream library (char instantion) :
Classes :
|
ios_base Base | ios | istream | ostream | iostream | ifstream | ofstream |
fstream | istringstream |
ostringstream
| stringtream | streambuf | filebuf | stringbuf |
Objects :
| cin
| cout | cerr | clog |
Types :
|
fpos : | streamoff | streampos | streamsize |
Manipulators :
|
boolalpha | dec | endl | ends | fixed | flush | hex | internal | left |
noboolalpha | noshowbase |
noshowpoint
| noshowpos | noskipws | nounitbuf | nouppercase | oct | resetiosflags | right
|
scientific
| setbase | setfill | setiosflags | setprecision | setw | showbase | showpoint
| showpos |
skipws
| unitbuf | uppercase | ws |
Objek
iostream mewarisi semua anggota yaitu istream dan ostream, sehingga mampu
melakukan
kedua operasi input dan output.
2. Library stdio.h
Library
stdio.h adalah library pada bahasa C yang digunakan untuk operasi input output
(stdio =
Standard
Input and Output). Tanpa menggunakan library ini maka perintah - perintah
input/output
tidak dapat dieksekusi atau dijalankan.
Library Functions :
|
clearr() | fclose() | fccloseall() | fdopen() | fflush() | fgetc() | fgetchar()
| fgetpos() | fgets() |
flushall()
| fopen() | fprint() | fputc() | fputchar() | fputs() | fread() | free() |
freopen() | fscan() |
fseek()
| fsetpos() | ftell() | fwrite() | gets() | getw() | perror() | printf() |
puts() | putw() | rename() |
rewind()
| scanf() | unlink() |
Library Macroes :
|
feof(f) | ferror(f) | fileno(f) | getch(f) | getchar(f) | putchar(f) |
remove(path) |
Contoh penggunaan library stdio.h dengan
library functions printf() dalam program :
#include
<stdio.h>
int
main()
{
printf("HelloWorld!\n");
printf("Selamat
Belajar C Program.");
return
0;
}
Contoh penggunaan library stdio.h dengan
library functions puts() dalam program :
#include
<stdio.h>
#include
<conio.h>
using
namespace std;
int
main()
{
char
x[20]="Ilmu Komputer";
puts("Sekolah
Siap Kerja Hanya di ");
puts(x);
return
0;
}
3. Library math.h
Library
math.h merupakan sebuah library yang disediakan untuk melakukan perhitungan
secara
matematika
dan mendefinisikan fungsi matematika umum .
Library Functions :
|
abs() | acosh() | asin() | atan() | atan2() | atof() | ceil() | cos() | cosh()
| exp() | fabs() | floor() |
fmod()
| labs() | ldexp() | log() | log10() | pow() | sin() | sinh() | sqrt() | tan()
| tanh() |
Contoh penggunaan library math.h dengan
library functions cos() dan sin() dalam program :
//Penggunaan
library math.h
#include
<iostream.h>
#include
<math.h>
using
namespace std;
int
main(){
double kecepatan, jarak, sudut;
kecepatan=20;
sudut=25;
jarak = 2*kecepatan*kecepatan*sin(sudut*3.14/180)*cos(sudut*3.14/180)/9.8;
cout<<"Jarak
= "<<jarak;
cout<<"\n";
system("Pause");
return 0;
}
4. Library stdlib.h
Library
stdlib.h mendefinisikan fungsi konversi numerik , pseudo-acak nomor fungsi
generasi ,
alokasi
memori , fungsi kontrol proses. Library stdlib.h merupakan library yang hampir
sama
dengan
library math.h, namun isi dari library stdlib.h berbeda dengan library math.h
yaitu :
Library Functions :
|
abs() | atof() | atoi() | atol() | div() | exit() | free() | ldiv() | malloc()
| rand() | srand() | system() |
Library Macroes :
|
abs(x) | atoi(s) | random(num) | randomize() |
Contoh penggunaan library stdlib.h
dengan library functions atoi() dalam program :
//Penggunaan
library stdlib.h
#include
<iostream.h>
#include
<stdlib.h>
using
namespace std;
int
main(){
char karakter[8]="12.3AB";
int nilai;
nilai=atoi(karakter);
cout<<nilai<<endl;
system("Pause");
return 0;
}
5. Library string.h
Suatu
library pada bahasa C yang digunakan untuk memberikan nilai suatu karakter string.
Librari Functions :
|
strcpy() | strcat() | strchr() | strcmp() | strlen() |
Contoh penggunaan library string.h
dengan library functions strcpy() dalam program :
//Penggunaan
library string.h
#include
<iostream.h>
#include
<string.h>
using
namespace std;
int
main(){
char info[30];
strcpy(info,
"info: Ilmu Komputer");
cout<<info;
cout<<"\n";
system("Pause");
return
0;
}
6. Library conio.h
Library Functions :
|
clrscr() | getch() | getche() | gotoxy() | khbit() | putch() |
Contoh penggunaan library conio.h dengan
library funtions getche() atau getch() dalam
program :
//Penggunaan
library conio.h
#include
<iostream.h>
#include
<conio.h>
using
namespace std;
int
main(){
cout<<"Selamat
datang mahasiswa baru Ilmu Komputer \n";
getche();
}
7. Library io.h
Library Functions :
|
access() | _close() | close() | _creat() | eof() | filelenght() | _open() |
open() | _read() | read() |
_write()
| write() |
8. Library ctype.h
Library Functions :
|
stlower() | toupper() |
Library Macroes :
|
isalnum( c) | isalpha( c) | isascii( c) | iscntrl( c) | isdigit( c) | isgraph(
c) | islower( c) | isprint( c) |
ispunct(
c) | isspace( c) | isupper( c) | isxdigit( c) | toascii( c) | _tolower( c) |
_toupper( c) |
Tidak ada komentar:
Posting Komentar