libfort/examples/4-fill_table.cpp

30 lines
744 B
C++
Raw Permalink Normal View History

2019-09-22 09:27:47 +02:00
#include <iostream>
#include <vector>
#include "fort.hpp"
int main(void)
{
2019-09-28 10:02:34 +02:00
fort::char_table table;
2019-09-22 09:27:47 +02:00
table << fort::header;
/* Fill each cell with operator[] */
table [0][0] = "N";
table [0][1] = "Planet";
table [0][2] = "Speed, km/s";
table [0][3] = "Temperature, K";
table << fort::endr;
/* Fill with iostream operator<< */
table << 1 << "Mercury" << 47.362 << 340 << fort::endr;
/* Fill row explicitly with strings */
table.write_ln("2", "Venus", "35.02", "737");
/* Fill row with data from the container */
std::vector<std::string> arr = {"3", "Earth", "29.78", "288"};
table.range_write_ln(std::begin(arr), std::end(arr));
std::cout << table.to_string() << std::endl;
}