When posting code if you put it in
then indentation will be preserved.
The casts in the following 2 statements are not required and it is probably better to leave them out.
memset((char*)&arr[0][0], 0, 400);
f = fopen((const char*)"C:\\Ex.txt","r+");
This line of code is open to error
arr[i][j] = fgetc(f);
the prototype of fgetc is
int fgetc( FILE *stream );
but you have imediately assigned it to char demoting it's type. You have no garunttee that EOF will fit in a char (especially if char is unsigned on the platform in question). To ensure correct operation and portability you should assign the return of fgetc to a int variable, check it against EOF and if it is not EOF then you should assign it to a char (if required).
This line is checking for EOF
else if(arr[i][j]==(-1))
you have no garunttee for any given platform that EOF is -1. You should use the defined symbol EOF as this is correct for all platforms.