This is why your program doesn't stop.
Code:
if (counter > 0 && counter >= 10)
file[1] = 't';
else if(counter > 10 && counter >= 20)
file[1] = 'm';
else if(counter > 20 && counter >= 30)
file[1] = 'w';
else if(counter > 30)
{
cout << "breaking";
break;
}
Take for example the first line. If counter > 0 and counter >= 10. If counter >= 10, then automatically counter > 0. Isn't it? So it would suffice if counter > 0..... but assume counter == 31. Then counter > 0!! So when counter > 0, then your program will ALWAYS go in the line file[1]='t'.
By the way, don't use that while (1). I, personally, would never use while (1) in a program like this.
You know that the program should break the loop when counter > 30. Knowing this condition it would be better to it this way:
Code:
while (counter++ <= 30)
The last thing you need to change is the range checking. I assume you want to do this:
Code:
if (counter > 0 && counter <= 10)
file[1] = 't';
else if(counter > 10 && counter <= 20)
file[1] = 'm';
else if(counter > 20 && counter <= 30)
file[1] = 'w';
else if(counter > 30)
{
cout << "breaking";
break;
}