Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <stdio.h>
- #include <string.h>
- #define FLUSH while(getchar() != '\n')
- void programUtama() {
- cout << "Program Utama\n\n";
- /*
- TULIS PROGRAM UTAMA ANDA DI SINI
- */
- }
- int main() {
- char *username = "123",
- *password = "123",
- input_username[100], input_password[100];
- int coba = 0;
- do {
- cout << "Masukkan username: ";
- cin >> input_username;
- FLUSH; // FLUSH BUFFER
- cout << "Masukkan password: ";
- cin >> input_password;
- FLUSH; // FLUSH BUFFER
- if(strcmp(input_username, username) == 0 && strcmp(input_password, password) == 0) {
- cout << "Login Berhasil\n\n";
- programUtama(); // <<-- JALANKAN PROGRAM UTAMA JIKA LOGIN BERHASIL
- return 0; // <<-- KELUAR DARI LOOPING DAN PROGRAM
- }
- cout << "\n====================================\n";
- cout << "Maaf USERNAME & PASSWORD ANDA Salah!\n";
- cout << "====================================\n\n";
- coba += 1;
- } while(coba < 3); // ULANGI MEMASUKKAN USERNAME DAN PASSWORD SAMPAI 3X JIKA TERJADI KESALAHAN
- cout << "Anda Telah 3x Memasukan ID & PASSWORD Yang Salah\n";
- cout << "Mohon Maaf kesempatan Anda hanya 3x ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement