Hey guys, strange error I'm getting at the moment. Visual Studio is saying that 'unit_counter2' is undeclared yet it's used in the code before the line on which it is meant to be undeclared, if you know what I mean? The variable is definatly used before that line and is definatly, therefore, declared.
This is the section of code which creates the problems which appears at the very end of my programme.
ofstream fileout;
string unitback;
unitback = "unitfile.txt";
fileout.open( unitback.c_str() );
while ( unit_counter2 >= 0 )
{
fileout << unit_id_st[unit_counter2];
fileout << unit_type_st[unit_counter2];
fileout << unit_side_st[unit_counter2];
fileout << unit_x_st[unit_counter2];
fileout << unit_y_st[unit_counter2];
fileout << unit_turn_st[unit_counter2];
fileout << unit_hp_st[unit_counter2];
fileout << unit_status_st[unit_counter2];
if (unit_counter2 != 0)
{
fileout << endl;
}
unit_counter2++;
}
fileout.close();
Any ideas why this bit of the code creates errors?