Archived

This topic is now archived and is closed to further replies.

-Tony-

for loop woes

Recommended Posts

Why does this only print out the first numbers?

int Array[2][2] = {1, 2,
                   3, 4};
 int x = 0;
 int y = 0;

 for(; x < 2; ++x)
  for(; y < 2; ++y)
   std::cout << Array[x][y] << std::endl;

but this prints out the whole array.

int Array[2][2] = {1, 2,
                   3, 4};

 for(int x = 0; x < 2; ++x)
  for(int y = 0; y < 2; ++y)
   std::cout << Array[x][y] << std::endl;

I''m using Visual C++ .NET 2003

Share this post


Link to post
Share on other sites