Article View: be.comp.programming
Article #16626Re: C warning
From: Philip
Date: Wed, 26 Apr 2000 00:00
Date: Wed, 26 Apr 2000 00:00
90 lines
3025 bytes
3025 bytes
Dit is een voorbeeldje
#define M 32
#define N 11
#define decimaal_deel(x) (x- (int) x);
main()
{
char a[M];
float b[N];
int i;
int lexico(void *, void *);
int compare_decimaal_deel(void *, void *);
// tabel vullen
qsort(A,M,sizeof(char),lexico);
// tabel afdrukken
}
int lexico(void *, void *)
{
char *p = vp, *q = vq;
return (*p - *q);
}
int compare_decimaal_deel(void *, void *)
{
float *p = vp, *q = vq, x;
x =decimaal_deel(*p) - decimaal_deel(*q);
return((x == 0.0) ? 0 : (x < 0.0) ? -1 : +1);
}
Ares Lagae wrote:
>
> Ik krijg volgende warning als ik mijn proggie compileer:
>
> bash-2.03$ gcc main2.c
> /xxxxxx/tmi/dppdoorloop.c: In function `dppdoorloop':
> In file included from main2.c:5:
> /xxxxxx/tmi/dppdoorloop.c:31: warning: passing arg 4 of `qsort' from
> incompatible pointer type
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *))
dus .. int point_compare(void *, void *) maar in jouw geval wel
aanpassen dan eh
> code vd quicksort:
> qsort(p, (size_t) num_p, (size_t) sizeof(point), point_compare);
>
> compare functie:
> int point_compare(point *p1, point *p2) //compare 2 points
> {
> if ((*p1).x < (*p2).x) {
> return -1;
> ` } else if ((*p1).x == (*p2).x) {
> if ((*p1).y < (*p2).y) {
> return -1;
> } else if ((*p1).y == (*p2).y) {
> return 0;
> } else {
> return 1;
> }
> } else {
> return 1;
> }
> }
>
> point:
> typedef struct point // structure to hold a point
> {
> double x;
> double y;
> } point;
>
> --
> Ares Lagae
--
Philip van Hoof aka freax _/_/_/
irc: freax @ undernet.org _/_/ _/ _/_/ _/_/_/ _/_/ _/ _/
http://users.pandora.be/skatan _/_/ _/ _/ _/ _/ _/ _/ _/
mailto:freax@pandora.be _/_/_/_/ _/ _/ _/_/ _/_/_/_/ _/_/
Hey, it will happen. They'll _/_/ _/ _/ _/ _/ _/ _/
go where the money is(Linus)_/_/ _/ _/_/_/ _/ _/ _/ _/
Technical Details
Message-ID:
<3906FF57.D606E795@pandora.be>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3906B643.438814CD@student.kulak.ac.be>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcea4,c99c916367dfb9ec X-Google-Attributes: gidfcea4,public From: Philip <freax@pandora.be> Subject: Re: C warning Date: 2000/04/26 Message-ID: <3906FF57.D606E795@pandora.be> X-Deja-AN: 615921539 Content-Transfer-Encoding: 7bit References: <3906B643.438814CD@student.kulak.ac.be> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@pandora.be X-Trace: afrodite.telenet-ops.be 956759896 195.130.128.118 (Wed, 26 Apr 2000 16:38:16 MET DST) Organization: http://users.pandora.be/skatan MIME-Version: 1.0 Reply-To: freax@pandora.be NNTP-Posting-Date: Wed, 26 Apr 2000 16:38:16 MET DST Newsgroups: be.comp.programming