C Pointers

C

CBFalconer

pete said:
That's the point.
With nodeptr parameters instead of void * parameters,
the equivalent cmp function becomes:

int acmp(const nodeptr litem, const nodeptr ritem) {
... code using litem and ritem ...
}

... which is a simpler way to write it.

You have once more totally ignored the need to keep the node
maneuvering code independant yet linkable. This absolutely
requires the void* parameters.

I suspect I would not like to have to service any fairly
complicated system designed by you. I do not intend to keep on
repeating the same reasons and having them ignored.
 
P

pete

CBFalconer said:
You have once more totally ignored the need to keep the node
maneuvering code independant yet linkable. This absolutely
requires the void* parameters.

I suspect I would not like to have to service any fairly
complicated system designed by you. I do not intend to keep on
repeating the same reasons and having them ignored.

I challenge.

You write a C program that sorts a linked list with your
generic list sorting functions.

I'll rewrite it, making only two changes;
1 The parameters on the cmp function will be changed
from void * to nodeptr.
2 The cmp function definition will be simplified.

If the (void *) parameters on the cmp function
are really needed for anything,
then you should be able to come up with
program that I can't convert.

If you won't,
it's because you know that you can't.
 
M

Martien Verbruggen

I did NOT recommend converting arrays to lists.

The OP, however, has an array. So they would have to convert, even if
you don't recommend it.

Martien
 
C

CBFalconer

Martien said:
The OP, however, has an array. So they would have to convert, even
if you don't recommend it.

Following is my actual posting, which you snipped out:
 
C

CBFalconer

pete said:
.... snip ...

I challenge.

You write a C program that sorts a linked list with your
generic list sorting functions.

I'll rewrite it, making only two changes;
1 The parameters on the cmp function will be changed
from void * to nodeptr.
2 The cmp function definition will be simplified.

If the (void *) parameters on the cmp function are really needed
for anything, then you should be able to come up with program
that I can't convert.

If you won't, it's because you know that you can't.

The problem is not just the one program. It is the one or ten
dozen further programs that use the same list and sorting module,
unchanged, and which programs do all sorts of different things.
Not only do you want to write portable code, you want to write
reusable portable code.
 
P

pete

CBFalconer said:
The problem is not just the one program. It is the one or ten
dozen further programs that use the same list and sorting module,
unchanged, and which programs do all sorts of different things.

I've got three of them right here:
http://www.mindspring.com/~pfilandr/C/lists_and_files/string_sort.c
http://www.mindspring.com/~pfilandr/C/lists_and_files/file_sort.c
http://www.mindspring.com/~pfilandr/C/lists_and_files/file_parse.c
Not only do you want to write portable code, you want to write
reusable portable code.

The associated files are here:
http://www.mindspring.com/~pfilandr/C/lists_and_files/list_lib.h
http://www.mindspring.com/~pfilandr/C/lists_and_files/file_lib.h
http://www.mindspring.com/~pfilandr/C/lists_and_files/list_lib.c
http://www.mindspring.com/~pfilandr/C/lists_and_files/file_lib.c
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top