that is way too much...break it down into functions...

and do something like this

Code:
for(int i = 0; i < x; i++)
{
      for(int j = 0; j < y; i++)
     { 
           char *c = something[i][j];
           if(c == somethingelse)
                //something
           foo[i][j] = *c;
     }
}