How to remove {} from the output?
#include <iostream>
#include <vector>
#include <fmt/format.h>
#include <fmt/ranges.h>
int main () {
std::vector<int> v = {1,2,3};
std::string s = fmt::format("{}", v);
std::cout << s << '\n'; // output : {1, 2, 3}
return 0;
}
how to remove '{' and '}' in output for the above code and only print : 1, 2, 3
Convert Vector to String using toString() function To convert elements of a Vector to Strings in R, use the toString() function. The toString() is an inbuilt R function used to produce a single character string describing an R object.
{fmt} is an open-source formatting library providing a fast and safe alternative to C stdio and C++ iostreams.
To use the {fmt} library, add fmt/core. h , fmt/format. h , fmt/format-inl. h , src/format.cc and optionally other headers from a release archive or the Git repository to your project.
I quote the fmt api:
#include <fmt/ranges.h>
std::vector<int> v = {1, 2, 3};
fmt::print("{}", fmt::join(v, ", "));
// Output: "1, 2, 3"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With