Ok, long story short, I'm trying to do some basic C++ and I'm stuck. I'm trying to output stuff to a txt file, but the way they want us to do it we need to split everything into functions. So I have the commant to open the output stream:
ofstream output("triangle.dat");
Then further down I have a command for the program to go to a void function, and then after the main function I have the void function itself:
void IsoscOrScale (int A, int B, int C) {
if (A == B || B == C || A == C)
output << "Isosceles ";
else
output << "Scalene ";
The problem I'm having is that since this is outside of the main function, it doesn't recognize the command to output those strings. I can re-define the output stream in this void function, and then it works, but I think re-defining it starts fresh, so it erases all the other stuff in the outputted .txt file and I end up with JUST that string.
If that doesn't make sense I can elaborate more, but basically how do I get it to continue to write to the output file when it goes down to a separate function? Thanks for the help from anyone who might know.
ofstream output("triangle.dat");
Then further down I have a command for the program to go to a void function, and then after the main function I have the void function itself:
void IsoscOrScale (int A, int B, int C) {
if (A == B || B == C || A == C)
output << "Isosceles ";
else
output << "Scalene ";
The problem I'm having is that since this is outside of the main function, it doesn't recognize the command to output those strings. I can re-define the output stream in this void function, and then it works, but I think re-defining it starts fresh, so it erases all the other stuff in the outputted .txt file and I end up with JUST that string.
If that doesn't make sense I can elaborate more, but basically how do I get it to continue to write to the output file when it goes down to a separate function? Thanks for the help from anyone who might know.