linucx c

how to open a browser and plot map values using linux c program?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdlib>
#include <fstream>
#include <string>
#include <map>

using map_type = std::map< std::string, int >;

std::string toRow( const map_type::iterator& iter )
{
  std::string ret;
  ret += "<tr><td>" + iter->first + "</td><td>" + std::to_string( iter->second ) + "</td></tr>";
  return ret;
}

int main( void )
{
  map_type my_map;
  my_map["New York"] = 8336697;
  my_map["Los Angeles"] = 3857799;
  my_map["Chicago"] = 2714856;

  std::ofstream output("map.html");
  output << "<table><tr><th>City</th><th>Population</th></tr>";
  for ( auto iter = my_map.begin(); iter != my_map.end(); ++iter )
    output << toRow( iter );
  output << "</table>";
  output.close();

  system("x-www-browser map.html");
  return 0;
}


Oh dang, you want this in c?
Last edited on
Topic archived. No new replies allowed.