Search code examples
c++stringcgal

Convert double and vertex handle into a string in c++


I want to convert a vertex handle(vit) and double value to string and write it into a file.I thought this works.

string buffer = vit->point() + " " +z_co[vit->id] +"\n";

z_co:is a vector.(double) But,it is throwing error.So,How could I do this?


Solution

  • You can't append a double to string like that.

    Instead use e.g. std::ostringstream:

    std::ostringstream os;
    os << vit->point() << " " << z_co[vit->id] << '\n';
    std::string buffer = os.str();