Materi 4 - Struct Atau Record
Materi 4 - Struct Atau Record
Email : [email protected]
http://euismarlina.edublogs.org
HP : 08179424319
struct nama_struct
{
tipe_data_member1 nama_member1;
tipe_data_member2 nama_member2;
tipe_data_member3 nama_member3;
}nama_objek;
struct product
{
int weight;
float price;
}apple, banana, melon;
Mata Kuliah Struktur Data - 2008
Mengakses Member
Untuk mengakses member struct pada
masing2 objek, gunakan tanda titik(.) yang
disisipkan antara nama objek dan nama
member struct.
Contoh :
apple.weight
apple.price
banana.weight
banana.price
melon.weight
melon.price
Mata Kuliah Struktur Data - 2008
Contoh Program 1
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
struct movies_t
{
char title[50];
int year;
} mine, yours;
int main ()
{
char mystr[5];