In this post, I am going to explain how you can be able to create a C++ Local Chatting System that will be used to chat over your LAN or Wireless network using only your computer or Laptop.
In this program, we have 6 files


The first file is the one we will be using to do Admin stuffs like(view all users, search from available users, sort users, remove a specific user, remove all users and count all users).

The second file is used to do User stuff like(create a new account, log in to the system before the user trying to communicate with users)

The third file will be used to do all the user-related kinds of stuff like(view their profile, find friends and get the users id for communication, update profile like changing password, name, phone number, and email address).

The fourth file is responsible for showing navigation key for the Admins which includes(1 to Remove user, 2 to view all users, 3 to search user, 4 to sort user, 5 to view developers, 6 to remove all users, 7 to the count all users, and 8 for logging out from the system).

The fifth file is the one the will be used to show the system users the navigation keys.

The sixth and the last one is the userMessage.h which is responsible for sending and showing the user message if there is anything new received.
Let's get into the main topic.

1. Admin.cpp

In the admin.cpp file is as the name suggests what it does is to do some admin stuff. Let's view all the codes we have for the admin.

In the below line we have imported c++ pre-defined libraries that will help us do some manipulation and also inline 6 we have imported a local header file that will be used to show the admin navigation.

#include "iostream"
#include "conio.h"
#include "stdlib.h"
#include "stream"
#include "string.h"
#include "menuBar.h"
using namespace std;

The next thing we need to do is to declare our variable and functions so that we can define, use, and override them later on.

Inline 9 we declare an integer variable choice that will help us do the navigation choice.

from lines 11-6 we have declared our functions before we call them.

int choice;

void viewAllUsers();
void searchUser();
void sortUser();
void removeUser();
void removeAllusers();
void countUsers();

Then next we will define our main function which we be called first when the cpp program is running.

int main() {

        cout<<"\n\t\t\tPress Enter To Continue : ";

    do {
        choice = enterChoice();
            switch(choice) {
                case 1:menuBar(); removeUser();     break;
                case 2:menuBar(); viewAllUsers();   break;
                case 3:menuBar(); searchUser();     break;
                case 4:menuBar(); sortUser();       break;
                case 5:menuBar(); groupMembers();     break;
                case 6:menuBar(); removeAllusers(); break;
                case 7:menuBar(); countUsers();     break;
                case 8:choice = 8;  break;
                default:choice = 0;  

    } while(choice != 8);
    cout<<"\n\t\tYour Session Cleared Sucessfully\n\t\tPress Enter To continue";

As you can see in the above code we have called about 7 function but currently they are not defined in order to make them work we need to define.

The first function we will define is removeUser() that this function does is it accepts the userName that will be removed and then try to find the user info from the UserDatabase.SQL binary file which is shared between the computer and if it finds the user it removes and show the admin the user have successfully removed and also its messages are removed.

void removeUser() {
    fstream userDB, userDB1;
    userInfo UI;
    char userName[15], firstName[15], lastName[15], userMessage[100] = "Z:\\chatFiles\\", ch;
    int isAvailable = 0, delUser = 0, isDeleted = 0;"Z:\\chatFiles\\UserDatabase.SQL", ios::in | ios::binary);"Z:\\chatFiles\\UserDatabase1.SQL", ios::out | ios::app | ios::binary);

    cout<<"\n\t\tEnter The UserName To Remove ->> ";
    cin.get(userName, 10);

        while( *)&UI, sizeof(UI))) {
             delUser = 0;
            if(strcmp(userName, UI.userName) == 0) {
                isAvailable = 1;
                cout<<"\n\tDo You Want to Remove "<>ch;
                    if(ch == 'Y' || ch == 'y') {
                        delUser = 1;
                        isDeleted = 1;
                strcpy(firstName, UI.firstName);
                strcpy(lastName, UI.lastName);
                strcat(userMessage, UI.userName);
                strcat(userMessage, ".SQL");
            if((delUser == 0) || (strcmp(userName, UI.userName) != 0)) {
                userDB1.write((char *)&UI, sizeof(UI));


        if(isAvailable == 0) {
           cout<<"\n\t\tThere is No User With This UserName!";
        if(isDeleted == 1){
            cout<<"\t   [**] Removing User...................... Sucessfull";
            cout<<"\t   [**] Deleting Messages.................. Sucessfull";
            cout<<"\t   [**] Clearing All User Catch Files...... Sucessfull";
            cout<<"\t   [**] LoggingOut User From All Devices... Sucessfull";
            cout<<"\t   [**] is All Action Completed............ Sucessfull";