You may like to file your data using commas to delimit the data record fields.
That way you can easily handle missing fields:
MovieName1,Genre1,HeroOfMovie1,HeroineOfMovie1
MovieName2,Genre2,,HeroineOfMovie2
MovieName3,Genre3,HeroOfMovie3,
And display as:
MovieName1::::Genre1::::HeroOfMovie1::::HeroineOfMovie1
MovieName2::::Genre2::::NA_HERO::::HeroineOfMovie2
MovieName3::::Genre3::::HeroOfMovie3::::NA_HEROINE
This example of sorting data records and finding data records using the C++ library functions may help you to get started.
This example uses an array of Student records. It demo's the idea of sorting on various fields and finding records that have particular field values.
// sortStudentsById_with_find2.cpp //
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype> // re. tolower ...
#include <algorithm> // re array sort, find, etc...
#include <vector>
using namespace std;
const int SIZE_STUDENT_ARY = 5;
class Student
{
public:
// ctors...
Student() : age(0), grade(0), id(0) {}
Student( int age, int grade, int id, const string& name )
: age(age), grade(grade), id(id), name(name) {}
void setAge( int age ) { this->age = age; }
void setGrade( int grade ) { this->grade = grade; }
void setId( int id ) { this->id = id ; }
void setName( const string& name ) { this->name = name ; }
int getAge() const { return age; }
int getGrade() const { return grade; }
int getId() const { return id; }
string getName() const { return name; }
void print( ostream& os ) const
{
os << left << setw(14) << name << ' '
<< setw(7) << id << ' '
<< setw(7) << grade << ' '
<< age << …