0
#include <iostream>
#include <conio.h>
#include <cstring>
#include <string>
using namespace std;
int main(){
    int kod;
    cout<<"Masukkan kode pendaftaran : ";cin>>kod;
    cout<<"\n";
    cout<<"Berhasil mendaftaran kode pendaftaran "<<kod<<endl;

    const int x=30;
    char nama[x]; char alamat[30];
    cout<<"Form pendaftran "<<endl;
    cout<<"Nama lengkap   : ";cin.getline(nama,x);
    cout<<"Alamat lengkap : ";cin.getline(alamat,x);
    string kelas, nisn;
    cout<<"Kelas          : ";getline(cin,kelas);
    cout<<"NISN           : ";getline(cin,nisn);
    for(int i=0; i<=164; i++){
        cout<<"=";
    }
    cout<<"[Berhasil mendaftar data]"<<endl;
    cout<<"["<<nama<<"]\n";
    cout<<"["<<alamat<<"]\n";
    cout<<"["<<kelas<<"]\n";
    cout<<"["<<nisn<<"]\n";
}

I can't give value on variable named 'nama' with the cin.getline() function and like this will happen

Nama lengkap : Alamat lengkap : example

below is the full output view

output display

0 Answers0