contoh struktur
struct mhs
{
char *nama;
char *nim;
int uts, uas;
float akhir;
char nutu;
}
contoh program
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
struct movies_t
{
char title[50];
int year;
}mine, yours;
void printmovie(movies_t movie);
int main()
{
char buffer[50];
strcpy(mine.title, "2001 A space odyssey");
mine.year = 1968;
cout<<"Masukkan Judul Film Favorite : ";
cin.getline(yours.title,50);
cout<<"Masukkan Tahun : ";
cin.getline(buffer,50);
yours.year=atoi(buffer);
cout<<"judul Film Yang Ada : \n";
printmovie(mine);
cout<<"judul Film Faforitmu adalah : \n";
printmovie(yours);
return 0;
}
void printmovie(movies_t movie)
{
cout<<movie.title;
cout<<"("<<movie.year<<")\n";
}
0 komentar:
Posting Komentar