Just as a reminder, move the red statements to where shown in blue. This is a scoping issue that will affect portability of C code. It's great in C++.
Code:
main ()
{
int i;
char j;
char *ip;
FILE *fp;
char filename[17] ;
for (i = 0; i < 10; i++)
    {
	ip=&j;
        for (j = 0; j<3; j++)
	{
	    FILE *fp;
            char filename[17] ;
...