Breaking News
Loading...
Sabtu, 19 Maret 2016

Membuat Struct secara dinamis



1.       Membuat struct secara dinamis dengan Dev C++ :

#include <iostream>
#include<conio.h>
//#include<iostream.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {

struct mahasiswa{
  char nim[15];
  char nama[30];
  char alamat[50];
};

   mahasiswa mhs;
   cout<<"Nama   : "; cin>>mhs.nama;
   cout<<"Nim    : "; cin>>mhs.nim;
   cout<<"Alamat : "; cin>>mhs.alamat;

   cout<<endl<<endl;
  
   cout<<"Nama Anda   : "<<mhs.nama<<endl;
   cout<<"Nim Anda    : "<<mhs.nim<<endl;
   cout<<"Alamat Anda : "<<mhs.alamat<<endl;

getch();
}
 Hasil Compile-nya :

0 komentar:

Posting Komentar

Copyright © 2014 My Blog My Adventure All Right Reserved