There is just one last problem. When i compile the code with Turbo C 2.01 from Microsoft Corp i get the 2 errors. They occur at. This is for the void printrestaurant(). What's going on? Some help here please...line 19 & 44 : Argument list syntax error
Here's the code:
And that's it!Code:/* Array Of Structures containing Restaurant Details */ # include <stdio.h> # include <stdlib.h> # include <ctype.h> # include <conio.h> # include <string.h> #define N_restaurant 5 char target[20]; int n,j; struct restaurant_t { char Name [100]; char address[30]; double av_cost; char food_type[20]; } restaurants [N_restaurant]; void printrestaurant (restaurant_t restaurant); void sort(); int main () { char buffer [50]; for (n=0; n<N_restaurant; n++) { printf("Enter Restaurant Name: "); gets (restaurants[n].Name); printf("Enter Address: "); gets (restaurants[n].address); printf("Enter Food Type: "); gets (restaurants[n].food_type); printf("Enter Cost: "); gets (buffer); restaurants[n].av_cost = atof (buffer); } printf ("\nYou have entered these restaurant:\n"); sort (); return 0; } void printrestaurant(restaurant_t restaurant) { if (strcmp(target,restaurant.food_type)==0) { printf ("Restaurant Name="); printf ("%s\n",restaurant.Name); printf ("Address="); printf ("%s\n",restaurant.address); printf ("Food Type="); printf ("%s\n",restaurant.food_type); printf ("Cost="); printf ("%.2f\n",restaurant.av_cost); } } void sort () { char tName [100]; char taddress[30]; double tav_cost; char tfood_type[20]; for (n=0; n<(N_restaurant-1); n++) for (j=n+1; j<N_restaurant; j++) if (restaurants[n].av_cost>restaurants[j].av_cost) { strcpy (tName,restaurants[n].Name); strcpy (restaurants[n].Name,restaurants[j].Name); strcpy (restaurants[j].Name,tName); strcpy (taddress,restaurants[n].address); strcpy (restaurants[n].address,restaurants[j].address); strcpy (restaurants[j].address,taddress); strcpy (tfood_type,restaurants[n].food_type); strcpy (restaurants[n].food_type,restaurants[j].food_type); strcpy (restaurants[j].food_type,tfood_type); tav_cost=restaurants[n].av_cost; restaurants[n].av_cost=restaurants[j].av_cost; restaurants[j].av_cost=tav_cost; } printf("Please enter the food type="); gets (target); for (n=0; n<N_restaurant; n++) printrestaurant (restaurants[n]); }



LinkBack URL
About LinkBacks



