Step 4 of 5
Write file
Use std::ofstream and a simple format (e.g. CSV with ;) to serialize each record.
std::ofstream out("inventario.txt");
for (const auto& p : inventario) {
out << p.id << ';' << p.nombre << ';' << p.precio << '\n';
}
out.close();