View Single Post
Old May 14th, 2006, 9:21 PM   #1
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
error C2065: 'unit_counter2' : undeclared identifier

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?
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote