Saturday 18 November 2017

C++ Program to Generate Date Between Given Range


Code:

#include    iostream
#include    map
#include    vector
#include    ctime

struct value {
    std::string code;
    std::string date;
    std::string name;
};

void Print_Range(std::vector & Data, value & Date_Start, value & Date_end)
{
    std::map Associated_Data;
    for(auto Date_Object : Array_Of_Dates)
    {
        time_t Object_Time = GetDateFromObject(Date_Object);
        Associated_Data.insert(std::make_pair(Object_Time, & Date_Object); 
    }
    //as the std::map is sorted by-default, 
    //we can know locate the iterator for any two time codes
    time_t Search_From = GetDateFromObject(Date_Start);
    time_t Search_To = GetDateFromObject(Date_End);
    auto Start_IT = Associated_Data.find(Search_From);
    auto End_IT = Associated_Data.find(Search_To);

    std::cout << "Printing all dates in range \n";
    for(auto IT=Start_IT; IT != End_IT; IT++)
    {
        std::cout << IT->Second->date << '\n';
    }
}


Output:

Execute and get the output.



More C++ Programs:
















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...