Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vector of ofstream* cannot open any element

In my project, I am trying to create a set of files for output. However, I am unable to open any of the ofstreams whenever I try to approach this. My best approach would use a vector of ofstream pointers shown below, but I am unable to open any of them.

        vector<ofstream*> out;
        for (int m = 0; m < p; m++)
        {
            for (int n = 0; n < p; n++)
            {
                string outname = "TLR" + to_string(n) + "|" + to_string(m) + ".txt";
                out.push_back(new ofstream{ outname.c_str() });
            }
        }

p is typically 5. is_open() reveals that nothing opens (duh). My program compiles and runs with no output. perror says "invalid argument." I am on visual studio 2013 running windows 10. What can I do to make this work? Thanks.

like image 272
Jeff Avatar asked Jan 24 '26 06:01

Jeff


1 Answers

The | character is not allowed in filenames on Windows. The ?,:,<,>, \, /, *, and " characters are also not allowed. All other printable unicode characters are valid.

like image 200
Miles Budnek Avatar answered Jan 26 '26 22:01

Miles Budnek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!