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
std::cout << s.substr(1, s.size()-2) << '\n';
– Adenoidal{
and postfix}
are hardcoded inranges.h
header. – Torras