#include <stdio.h>


     struct places
    {       
       char places1[100];
       char places[10][10];
       int distances[10][10];
    };

     
main()
{
 int menu;
 char userinput1[10];
 char userinput2[10];
 char userinput3[10];
 int cost;
 int other;
 int a;
 int b;
 int c;
 int distances;
 char places[50];
 struct places names[10]; 
 
FILE *fp; /*creates a file pointed named fp*/

/* reading in data from file*/
  do
  {
     printf("Enter file name");
     scanf("%s", places);
     fp = fopen(places,"r");
     if (fp == NULL)
     printf("File %s does not exist\n",places);
  }
  while(fp ==NULL);

while(feof(fp) ==0)
{
   for(int i = 0; i < 10; i++)
   {
     fscanf(fp, "%s", &names[i].places);
   }
     for(int i = 0; i < 10; i ++)
     {
       for(int j = 0; j < 10; j++)
       {
         fscanf(fp, "%d", &names.distances[i][j]);
       }
     }

    for(int i = 0; i < 10; i ++)
     {
      for(int j = 0; j < 10; j++)
       {
        for(int h = 0; h < 10; h++)
          {
           fscanf(fp, "%d", &names.distances[i][j][h]);
          }
       }
     }

 }


/* menu */

do
{
   printf("what would you like to do\n");
   printf(" 1: display mileage table");
   printf(" 2: calulate distances between points");
   printf(" 3: calulate cost of journey");
   printf(" 4: exit");
   scanf("%d", &menu);

 switch(menu)
 {
  case 1:
         display(distances, names);
         break;
  case 2:
        distance(distances, names);
        break;
  case 3:
        calc(distances,names);
        break;
  case 4:
        exit(0);
        break;
 }

}
while(menu<5 && menu > 0);

}

   /* display mileage chart*/

   int display(int distances[][10], struct places names[10])
   {
    printf(" mileage chart");
    printf("Burton Derby Swad Stoke Staff Lincoln Walsall Telford Cannock Warwick");

	for(int i = 0; i<10; i++)
	{
  	  for(int j = 0; j < 10; j++)
     	 {
   	  printf("%7s",names[i].places);
   	  printf("%7d", distances[i][j]);

        }
    }
}

/*distance between points*/
int distance( int distances[][10], struct places names[10])
{

	printf("Burton");
	printf("Derby");
	printf("Swad");
	printf("Stoke");
	printf("Stafford");
	printf("Lincoln");
	printf("Walsall");
	printf("Telford");
	printf("Cannock");
	printf("Warwick");

	printf("Enter the first point from the above list");
	scanf("%s", &userinput1);

	for (int i = 0; i<10; i++)
	{
  		if(strcmp(userinput1, names[i].places) ==0)
		{
  			a = i;
		}
   		else
   		{
        		printf("Please enter a place from the list");
   		}

		printf("Enter the second point from the above list");
		scanf("%s", &userinput2);

		for(int j = 0; j <10;j++)
		{
 			if(strcmp(userinput2, names[j].places) == 0)
			{
				b = j;
			}
			else
			{
     				printf("Please enter a place from the list");
			}

			printf("The distance is %d", distances[a][b]);

		}

		printf("Enter the third point from the above list");
		scanf("%s", &userinput3);

		for(int h = 0; h <10;j++)
		{
 			if(strcmp(userinput3, names[h].places) == 0)
			{
				c = h;
			}
			else
			{
     				printf("Please enter a place from the list");
			}

			printf("The distance is %d", distances[a][b][c]);

		}
}



/*calculations between points*/
int calc(int distances[][10], struct places names[10]);
  {
	printf("Burton");
	printf("Lincoln");
	printf("Walsall");
	printf("Telford");
	printf("Cannock");
	printf("Warwick");
	printf("Derby");
	printf("Swad");
	printf("Stoke");
	printf("Stafford");

	printf("Enter the first point from the list");
	scanf("%s", userinput1);

         for (int i = 0; i <10; i++)
	 {
	  if(strcmp(userinput1, names[i].places) == 0)
	   {
	     a = i;
	   }	
  	   else
  	   {
	    Printf("Please enter a point from the list");
	   }
	}


	printf("Enter the second point from the list");
	scanf("%s", userinput2);

	for(int j = 0; j < 10; j++)
	{
    	  if(strcmp(userinput2, names[j].places) ==0)
	  {
	   b = j;
	  }
	   else
	  {
	    Printf("Enter a point from the list");
	  }
       }

	printf("Enter the thrid point from the above list");
	scanf("%s", &userinput3);

	for(int h = 0; h <10;j++)
	{
	  if(strcmp(userinput3, names[h].places) == 0)
	   {
	    c = h;
	   }
	   else
	   {
 	   printf("Please enter a place from the list");
	   }

          printf("The distance is %d", distances[a][b][c]);

        }

	 if(distances[a][b][c] <= 100)	
	  {
    	   cost = ((distances[a][b][c] * 40)/100);
     	   printf("The cost is %d", &cost);
	  }
	   else
	  {
   	   other = distances[a][b][c] - 100;
   	   other = other * 30;
   	   cost = (100 * 40) + other;
  	   cost = cost/100;

           printf("The cost of the journy is %d", &cost);

      	 }
   }
}

Error message Line 7 In declartion "places", or no linkage an delared in same struct

how do i get this error message to go away

This question has already been answered. Start a new discussion instead.