Skip to content

🔥Coder's Guide to 🤖ChatGPT🔥

fox infotech logo new.
  • Tutorials
  • Courses
  • Online Tools
  • eBooks
  • Oracle Apex
  • Oracle Forms
  • PL/SQL
  • SQL
  • HTML
  • CSS
  • JavaScript
  • Python
  • PHP
  • R
  • Julia
Ask Question
Ask Question

🔥Coder's Guide to 🤖ChatGPT🔥

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

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 →

eBook

eBook

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 Remove the Background from an Image in JavaScript?
  • The Secrets of Facial Recognition Technology: How Do Machines Recognize Your Face?
  • The Behind-the-Scenes of Streaming Services: How Do They Deliver Content?
  • The Journey of a Text Message: From Sender to Receiver
  • What Happens When We Type URL in a Browser and Hit Enter?
  • How Quantum Computers Work: The Physics Behind Quantum Computing
  • How to Check If Char is Vowel in Rust?
  • Error: Python Interpreter is Not Selected [Solved]
  • Fix TypeError: 'float' object is not subscriptable in Python
  • TypeError: 'str' object does not support item assignment in Python
  • Fix error: subprocess-exited-with-error in Python
  • Fix SyntaxError: non-default argument follows default argument in Python
  • Fix TypeError: string indices must be integers in Python
  • Fix ValueError: could not convert string to float in Python
  • Fix TypeError: unhashable type: 'dict' in Python
  • Fix ModuleNotFoundError: No module named 'cv2' in Python
  • TypeError: 'module' object is not callable in Python
  • ValueError: too many values to unpack (expected 2) in Python
  • How to Resolve ModuleNotFoundError: No module named 'numpy' in Python?
  • How to Resolve IndentationError: Unexpected indent in Python?

Popular Tools

  • Escape HTML Online
  • JSON Editor Online
  • GUID 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
  • Cookie Policy
Our Sites
  • OrclQA.com (Q&AForum)
  • WebUtility.io (Online Tools)
License
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Copyright © 2023 foxinfotech.org