在 C++ 中,我想将 push_back double 无损地转换为 vector。 我该怎么办?
#include <vector>
int main()
{
std::vector<char> vv;
double d = 11.11;
vv.push_back(d);
printf("%f", d);
}
我想打印“11.11”。 有什么方法可以插入吗?
#include <vector>
#include <iostream>
int main()
{
//use properate type with STL
std::vector<double> vv;
double d = 11.11;
vv.push_back(d);
//printf("%f", d);//not suitable in cxx, use std::cout
std::cout << d <<std::endl;
//or u wana print out vv
for(auto i:vv)
std::cout << i <<std::endl;
}