Article View: borland.public.cppbuilder.nativeapi
Article #5020Compiler Error
From: chrism2
Date: Sat, 29 Oct 2005 02:59
Date: Sat, 29 Oct 2005 02:59
142 lines
4452 bytes
4452 bytes
Hello All,
I've tried to debug the code below, but can't figure out what is
causing the errors. I appreciate if anyone of you could give me a hand
on that. Follows the code and the error messages.
TIA,
-Chris
File "restaurant.h"
struct restaurant {
char *name;
char *address;
int average_cost;
char *food_type;
};
typedef struct restaurant DINER;
/********** Preprocessor
***********************************************/
#define MAX 3
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "restaurant.h"
/********** Functions
***************************************************/
int fill_out(DINER);
int print_out(DINER);
int compare_cost(const void *, const void *);
int print_rest(DINER,char *);
/********** main
*******************************************************/
int main()
{
DINER chain[MAX];
char *type[10];
fill_out(chain[MAX]);
printf("\n%s", "Enter the type of food desired: ");
scanf("%s",type);
printf("\n%s\n",type);
print_rest(chain[MAX],type);
print_out(chain[MAX]);
return 0;
}
/************************************************************************
*
* fill_out: Assign values to each array member (structure).
*
************************************************************************/
int fill_out(chain)
DINER chain[];
{
int i;
for (i = 0; i < MAX; ++i){
printf("Enter name: ");
scanf("%s",&chain[i].name);
printf("\n%s","Enter address: ");
scanf("%s",&chain[i].address);
printf("\n%s","Enter avg cost: ");
scanf("%d",&chain[i].average_cost);
printf("\n%s","Enter type of food: ");
scanf("%s",&chain[i].food_type);
printf("\n");
}
return 0;
}
/************************************************************************
*
* compare_cost: Compare two array members when qsorting.
*
************************************************************************/
int compare_cost(const void *ell1, const void *ell2)
{
DINER *el1 = (DINER*)ell1;
DINER *el2 = (DINER*)ell2;
if (el1 ->average_cost == el2->average_cost) return 0;
else if (el1->average_cost < el2->average_cost) return -1;
else return 1;
}
/************************************************************************
*
* print_rest: Print list of restaurants in ascending cost order
*
************************************************************************/
int print_rest(chain,type)
DINER chain[];
char *type;
{
int i;
printf("\n%s\n","Got in!!!");
qsort(&chain,MAX,sizeof(chain[1]),compare_cost);
for (i=0; i<MAX; i++)
if (strcmp(type,chain[i].food_type))
printf("%s\n",chain[i].name);
return 0;
}
Errors:
>bcc32 -v- -w -O1 13_4.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
13_4.c:
Warning W8075 13_4.c 33: Suspicious pointer conversion in function main
Error E2342 13_4.c 47: Type mismatch in parameter 'chain' (wanted
'restaurant', got 'undefined') in function fill_out
Error E2342 13_4.c 72: Type mismatch in parameter 'chain' (wanted
'restaurant', got 'undefined') in function print_out
Error E2342 13_4.c 110: Type mismatch in parameter 'chain' (wanted
'restaurant', got 'undefined') in function print_rest
*** 3 errors in Compile ***
>Exit code: 1
Technical Details
Message-ID:
<1130554789.204718.253930@g47g2000cwa.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b33f15cb68e8aff2,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail From: chrism2@gmail.com Newsgroups: borland.public.cppbuilder.nativeapi Subject: Compiler Error Date: 28 Oct 2005 19:59:49 -0700 Organization: http://groups.google.com Lines: 143 Message-ID: <1130554789.204718.253930@g47g2000cwa.googlegroups.com> NNTP-Posting-Host: 201.27.136.176 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1130554794 8597 127.0.0.1 (29 Oct 2005 02:59:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 29 Oct 2005 02:59:54 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=201.27.136.176; posting-account=AX3Y9w0AAACDwddjqyFcFKippgf-Dm1G