1
I have the tuple vector written in C++, defined as:
std::vector<std::tuple< float, float>> ASK_Mod;
I populated it, and tried to save it in a new file . txt as defined in the function, however, it only works for Vectors without tuples.
std::ofstream outfile("ASKModulation.txt");
outfile.open("ASKModulation.txt");
if(outfile.is_open())
{
std::copy(ASK_ModulatedWave.rbegin(), ASK_ModulatedWave.rend(), std::ostream_iterator<float>(outfile, "\n"));
}else
{
std::cout << "ERROR! Could not export!" << std::endl;
}
outfile.close();
The error that returns is:
/usr/include/c++/7/bits/stl_algobase. h:324:18: error: no match for ḍ Operator=' (operand types are ːStd::ostream_iterator' and ḍ Std::tuple') *__result = *__first;
How can I save the Ask_mod variable to a file. txt?
So, I liked what you did, but the generated file is empty, and I checked if it enters the loop you created, and enters, but does not record apparently
– FourZeroFive
@Fourzerofive The file was opened twice, in the constructor and in the open() method. This meant that the contents were not written. I updated the link to a working solution :)
– Arthur Passos
So grateful, so perfect!
– FourZeroFive