#include #include //for the macros EXIT_SUCCESS and EXIT_FAILURE #include //for class string and the functions stoi, stod #include "cgi.h" //for class cgi using namespace std; int main() { cout << "Content-type: text/html\n\n" //CGI MIME-type header, 2 newlines << "\n" << "\n" << "\n" << "Sign\n" << "\n" << "\n" << "\n" << "

Your Astrological Sign

\n"; //The constructor of c reads the data from the form that launched this //C++ program, or else it outputs an error message. const cgi c; const map& m {c.get_input()}; int month {0}; auto it {m.find("month")}; if (it == end(m)) { cout << "
Could not get month.\n"; } else { month = stoi(it->second); //string to integer } int day {0}; it = m.find("day"); if (it == end(m)) { cout << "
Could not get day.\n"; } else { day = stoi(it->second); //string to integer } struct sign { string name; int emoji; //Unicode number of the emoji, written in hexadecimal int month; int day; }; const sign a[] { {"Capricorn", 0x2651, 1, 19}, //Capricorn ends on January 19 {"Aquarius", 0x2652, 2, 18}, {"Pisces", 0x2653, 3, 20}, {"Aries", 0x2648, 4, 19}, {"Taurus", 0x2649, 5, 20}, {"Gemini", 0x264A, 6, 21}, {"Cancer", 0x264B, 7, 22}, {"Leo", 0x264C, 8, 22}, {"Virgo", 0x264D, 9, 22}, {"Libra", 0x264E, 10, 23}, {"Scorpio", 0x264F, 11, 21}, {"Sagittarius", 0x2650, 12, 21}, {"Capricorn", 0x2651, 12, 31} }; for (auto s: a) { //for each sign s in the array a, if (month < s.month || month == s.month && day <= s.day) { //In HTML, ’ is "right single quote" (apostrophe). cout << "Congratulations, you’re "; if (s.name[0] == 'A') { //If the 1st character is 'A' cout << "an"; } else { cout << "a"; } //Make the emoji bigger. cout << " " << s.name << "!\n" << "
\n" << "" << "&#x" << hex << s.emoji << "\n"; break; } } cout << "\n" "\n"; return EXIT_SUCCESS; }