Hi all, I am having a problem when trying to compile this.

from compiler:
error: name lookup of 'pixel_number' changed for new ISO 'for' scoping
error: obsolete binding at 'pixel_number'

I understand that I cannot use the pixel_number variable outside of the for loop, have read so in other posts. However, in this case it is in the for loops, inside of the if statement.

Do i need to pass it through a pointer so i do not change the variable?

//If file opens, read in data, starting at line 1;
if (In_file.is_open()) {
  for (int pixel_number = 1; pixel_number < 900; pixel_number++); {
  //Determine pixel coordinates
  In_file >> s_axis_1; 
  In_file.ignore(5, 'o');
  In_file >> s_axis_2;
  In_file.ignore(256 ,'s');
  In_file >> t_axis_1;
  In_file.ignore (5, 'o');
  In_file >> t_axis_2;
  temp_s_coordinate = (s_axis_2 - s_axis_1)/2 + s_axis_1;
  temp_t_coordinate = (t_axis_2 - t_axis_1)/2 + t_axis_1;
  //cout << s_axis_1 << "    " << s_axis_2 <<endl;
  //cout << t_axis_1 << "    " << t_axis_2 <<endl;

  //cout << temp_s_coordinate <<endl << temp_t_coordinate << endl;

  //Get pixel value
  In_file >> temp_value;
  In_file >> temp_error;
  //Store the values
  data[m][n].s_coordinate = temp_s_coordinate;
  data[m][n].t_coordinate = temp_t_coordinate;
  data[m][n].value = temp_value;
  data[m][n].error = temp_error;
  cout << temp_value << "   " << temp_error << endl;
  if ((pixel_number/30) == 0) {
   } else {
  cout << "Unable to open input file\n" << endl;


Thanks for the help


The block does no longer belong to the for loop, because you have a ; after the for.

Line 4: remove that semicolon at the end of the line. That is what is causing the error message.

Thanks guys, that worked great.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.