Hello guys, I am currently working on an insurance management system and i need help on how to use files and on how to create an admin side since I am new to this. Thank you

Dani AI

Generated

Quick orientation and practical next steps for (building on comments from and ):

A helpful starting point is a tiny schema and a sample file: what fields does a "policy" need (id, holder name, premium, start/end dates, status, etc.), and which operations must exist (create, read, update, delete, search). Decide whether the app will remain a single-user desktop program (file-based persistence OK) or grow into a multi-user/web system (server + database). As implied, that decision changes architecture; as suggested, a minimal reproducible example (one or two classes, sample input, compiler and OS) will let responders provide targeted fixes instead of generic advice.

Persistence options and trade-offs:

  • CSV: simplest, easy to inspect, poor for nested or optional fields.
  • JSON: human-readable, maps cleanly to C++ structures (good for moderate complexity).
  • Binary: compact, faster, but less portable and harder to debug.
  • SQLite: a single file but a full relational DB — recommended when queries, concurrent access, atomicity, or simple migrations are needed.
    If files are used, implement a single data-access layer (load/save/append) and protect writes with atomic replace (write to a ".tmp" file then rename) and file locking if concurrent processes are possible. Keep versioned backups.

Concrete C++ pattern (CSV skeleton)

#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <stdexcept>

struct Policy { int id; std::string holder; double premium; };

void savePolicies(const std::vector<Policy>& policies, const std::string& filename) {
    std::ofstream out(filename);
    if (!out) throw std::runtime_error("cannot open file");
    out << "id,holder,premium\n";
    for (const auto& p : policies) out << p.id << ',' << p.holder << ',' << p.premium << '\n';
}

std::vector<Policy> loadPolicies(const std::string& filename) {
    std::vector<Policy> res; std::ifstream in(filename); if (!in) return res;
    std::string line; std::getline(in, line); // skip header
    while (std::getline(in, line)) {
        std::istringstream ss(line); Policy p; std::string token;
        std::getline(ss, token, ','); p.id = std::stoi(token);
        std::getline(ss, p.holder, ',');
        std::getline(ss, token, ','); p.premium = std::stod(token);
        res.push_back(p);
    }
    return res;
}

Admin-side and security notes:
Start with a simple console admin menu (CRUD through the DAL). For production consider a web admin + REST API and a proper auth system; never store plaintext passwords (use a vetted hash library) and protect personally identifiable information. Common debugging items: wrong relative path, permissions, encoding, stream failbit — check return values and log errors.

What helps responders most: include a minimal reproducible example (one or two classes), the failing input or error text, the OS and compiler, and a short description of intended admin functionality.

Recommended Answers

All 4 Replies

About how to use files is quite the topic. You'll have to reveal how far along you are in your coursework or if you want to delete, read, alter or create said files. There are tutorials in abundance which you can use to catch up if you skipped taking classes.

But let's forget all that. Wouldn't a modern system build this as a web page with the backend on the server and you accessing such with a browser?
Also, where's your design document for such a system? Sometimes folk code first and design later.

commented: Actually I am in the basics in c++. currently on functions. I am done with the topic on file but am not getting how to use it the my project. +0

I was in the process of writing a response and after two sentences I realized I had already put more effort into replying than you did in creating the original post. Please show us what you have and where you are stuck.

commented: #include <iostream> #include <fstream> using namespace std; /* The SMM Insurance Management System */ //function prototypes void displayMenu(); void +0

My progress soo far. I need help on how to use the files in the project and also in creating the admin side. Also to know if I am on the right path.

You still haven't shown us that you have put any effort into doing this yourself. If you don't pony up then this thread will likely be ignored.

commented: Giddyup. +15
commented: I have been trying tom paste a copy but having a tough time doing that +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.