I love how in python I can do something like:
points = []
for line in open(\"data.txt\"):
a,b,c = map(float, line.split(\',\'))
points += [(a,b,c)]
<
The C++ String Toolkit Library (StrTk) has the following solution to your problem:
#include
#include
#include "strtk.hpp"
struct point { double x,y,z; }
int main()
{
std::deque points;
point p;
strtk::for_each_line("data.txt",
[&points,&p](const std::string& str)
{
strtk::parse(str,",",p.x,p.y,p.z);
points.push_back(p);
});
return 0;
}
More examples can be found Here