How would I populate a vector with mp3 files?
Jun 5, 2017 at 7:18am UTC
Is there a way to push back mp3 files in a vector?
Jun 5, 2017 at 8:32am UTC
Sure. You can any data push back to vector. You could handle your mp3 file as a stream of chars.
E.g.:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <fstream>
#include <vector>
#include <iostream>
int main()
{
std::vector<std::vector<char >> data_vec;
while ( true )
{
std::string filename;
std::getline(std::cin, filename);
std::ifstream ifstr(filename);
if (!ifstr) break ;
std::vector<char > data;
char byte;
while (ifstr.get(byte))
{
data.push_back(byte);
}
data_vec.push_back(data);
}
}
Last edited on Jun 5, 2017 at 8:34am UTC
Jun 5, 2017 at 10:27am UTC
What exactly is it that you want to push to the vector? The names of those files? Open streams for reading/writing to those files? The contents of those files?
Can you be more specific?
Topic archived. No new replies allowed.