Skip to content
fox infotech logo new.
  • Tutorials
  • Courses
  • Online Tools
  • Oracle Apex
  • Oracle Forms
  • PL/SQL
  • SQL
  • HTML
  • CSS
  • JavaScript
  • Python
  • PHP
  • R
  • Julia
fox infotech logo new.
Search
  • Oracle Forms
  • Oracle Apex
  • PL/SQL
  • SQL
  • Toad for Oracle
  • SQL Developer
  • CX-Oracle
  • Python
  • PHP
  • HTML
  • JavaScript
  • CSS
  • R
  • Julia
  • Java
  • Groovy
  • Linux
  • Cloud Computing
  • Artificial Intelligence
  • Cyber Security
  • Computer
Home » C++ » Login Authentication Program in C++

Login Authentication Program in C++

By Vinish Kapoor / September 18, 2021 September 18, 2021

Here is an example of a login authentication program in C++ using a dictionary object to store usernames and passwords.

Example: C++ Authentication Program

The following C++ program using the map function to create a dictionary object and using the map's find method to check whether the key exists or not.

#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
    // create your dictonary
    map<string, string>dict = { {"david", "123"} };
    string username, password;
    cout<<"Enter username: "<<endl; cin>>username;
    cout<<"Enter password: "<<endl; cin>>password;
    // Check if provided username and password matches with the one is dictonary
    if(dict.find(username) != dict.end() && dict[username] == password) {
        cout<<"Login Successfully!";
    } else {
        cout<<"Invalid Credentials";
    }
    return 0;
}

Output:

Enter username: 
david
Enter password: 
123
Login Successfully!

 

Post navigation
← Previous Post
Next Post →

Table of Contents

  • Example: C++ Authentication Program
    • Output:

Related Posts

  • Get Array Length in C++
  • C++ multimap Example
  • C++ Map Example
  • Variable Declaration in C++ Example
  • 10+ Programming Languages FizzBuzz Program Examples
  • Switching from Pointer to Member Functions in C++
  • How to Print Address of Iterator in C++?
  • macOS Error: DNSSD Crash After Calling fd_set on its Socket in C++
  • Making std::map::find Function Case Sensitive in C++ | Case Sensitive Search Using the map in C++
  • C++ Basics
  • How to Run C++ Program on Mac Terminal
  • Fibonacci Series in C++ (Recursion Example)

Latest Posts

  • How to Resolve error: "legacy-install-failure" in Python?
  • Fixing "ModuleNotFoundError: No Module Named apt_pkg" in Python
  • Fixing ModuleNotFoundError: No module named 'requests' in Python
  • Fix modulenotfounderror: no module named 'yaml' in Python
  • Fix Attributeerror: bytes object has no attribute 'read' in Python
  • Fix Error: metadata-generation-failed in Python
  • Fix Typeerror: list indices must be integers or slices, not str
  • Fix ParseIntError { kind: InvalidDigit } in Rust
  • How to resolve NameError: name 'nltk' is not defined in Python?
  • Rust: Convert Str to Int
  • CSS :checked - Apply Styles When Checkbox/Radio Checked
  • CSS :any-link - Apply Styles to All or Specific Links
  • CSS :active - Apply Styles on Click of an Element
  • CSS ::after Selector - Add Content After an Element
  • CSS ::before Selector - A Beginner's Guide
  • How to Create a Function in Rust?
  • 3 Ways to Make Text Bold in CSS
  • Rust: Check if a bit is set
  • The Application of Bio-Inspired Computing in Robotics and Computer Vision
  • Rust: Check if vectors are equal

Popular Tools

  • Escape HTML Online
  • JSON Editor Online
  • Strong Password Generator
  • Box Shadow CSS Generator
  • Constant Case Converter
  • Camel Case Converter
  • Pascal Case Converter
  • Image to Base64 Converter
  • Generate a Strong Password
  • PL/SQL Beautifier
  • CSS Beautifier & Minifier
  • JavaScript Beautifier
  • HTML Beautifier
  • Dummy Data Generator
  • Compare Text/Code
  • CSV to Chart
  • JSON to Table Converter
  • Number to Binary Converter
  • Blue Screen Test
  • Split Paragraph Into Sentences

Topics

  • Oracle Forms
  • Oracle Apex
  • PL/SQL
  • SQL
  • Toad for Oracle
  • SQL Developer
  • CX-Oracle
  • Python
  • PHP
  • HTML
  • JavaScript
  • CSS
  • R
  • Julia
  • Java
  • Groovy
  • Linux
  • Cloud Computing
  • Artificial Intelligence
  • Cyber Security
  • Computer
  • About
  • Contact
  • Privacy Policy
  • Web Stories
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Copyright © 2023 foxinfotech.in