>>filename="Synthesis//"+itoa(SynthNumber)+".txt";
I suspect that is the line that is wrong. The result of that is "Synthesis//1.txt", which has two / characters, not one. \ is the escape character, not /. So filename="Synthesis\\"+itoa(SynthNumber)+".txt" would be correct. If you want to use / then ok but you only need one of them.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Yup, you are right. That does work :)
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Ok so I was wrong about that (I tested it wih two / characters and it works.)
Try a simple program like this and see if it works or not
#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::string filename = "c://dvlp//test2//test2//";
for(int n = 1; n < 100; n++)
{
std::stringstream str;
str << filename;
str << n;
str << ".txt";
std::cout << str.str() << '\n';
}
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Since you are using the same ifstream object throughout the do/while -loop, you need to call tempsynth.clear() whenever .open() fails. Otherwise the object remains in fail state and makes no attempt to open any further files.
By the way, are you initializing the random number generator (i.e. calling srand() )?.
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395