// C++ Code #include #include #include using namespace std; void prepare_html(string *headers,string **data, int rows, int cols); int main() { int rows, cols; cout << "Enter the number of rows: "; cin >> rows; cin.ignore(); cout << "Enter the number of cols: "; cin >> cols; cin.ignore(); string *headers = new string[cols]; for (int i = 0; i < rows; ++i) { cout << "Enter the name of " << i + 1 << " Header: "; getline(cin, headers[i]); } string **data = new string *[rows]; for (int i = 0; i < rows; ++i) { data[i] = new string[cols]; } for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { cout << "Enter the " << headers[j] << " name for row " << i + 1 << ": "; getline(cin, data[i][j]); } } prepare_html(headers, data, rows, cols); for (int i = 0; i < rows; ++i) { delete[] data[i]; } delete[] data; return 0; } void prepare_html(string *headers,string **data, int rows, int cols) { string all_html = R"(

HTML Table

)"; all_html += ""; for (int i = 0; i < rows; ++i) { all_html += ""; } all_html += ""; for (int i = 0; i < rows; ++i) { all_html += ""; for(int j=0 ;j"; } all_html += ""; } all_html += R"(
" + headers[i] + "
)"; try { string fileName = "index.html"; ofstream outFile(fileName); if (!outFile.is_open()) { throw runtime_error("Error opening the file: " + fileName); } outFile << all_html; outFile.close(); std::cout << "String successfully saved to file: " << fileName << endl; } catch (const exception& e) { cerr << "Exception: " << e.what() << endl; } }