• Cara 1
struct nama_struct
{
type1 element1;
type2 element2; anggota / elemen dari struktur
type3 element3;
…
…
} nama_object;//identifier untuk pemanggilan struct
• Cara 2
struct nama_struct
{
type1 element1;
type2 element2;
type3 element3;
.
.} ;
nama_struct nama_object;
//atau struct nama_struct nama_object;
#include <iostream.h>
#include <conio.h>
struct stok {
char nama [50];
int jml;
};
#include <iostream.h>
#include <conio.h>
struct data_tgl
{ int tgl,bln,thn; };
struct teman
{ char nama[20];
char j_kel[1];
struct data_tgl tgl; };
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
main()
{
struct tanggal {
int hari;
int bulan;
int tahun;
};
struct alamat {
char jalan[30];
char kota[20];
};