--- Valnir <[EMAIL PROTECTED]> wrote:
> Well, since I don't have 100% C/C++ programming knowledge, I am not going to
> argue with either of you two (Mike/Kender)... all I know is that my Skills
> list sorts and his Helps sort ok by using the "Linked List" that you both
> are saying won't work...
> 
> Here is my question:
> 
> Once you read the file contents into memory, doesn't it technically become
> an array??? If it DOES, then you can sort it directly.

No, it does not. The reason that it _seems_ to be working in both cases is due
to the fact that you are probably allocating the memory sequentially, and not
adding or removing elements from the list before you try and sort it. Let me
assure you that calling qsort on a linked list is undefined behavior. Yes it
may work for you now, but next week it may not.. You can't tell because it's
not defined behavior. Using an array (either directly, or through a wrapper
function) does have a defined behavior and will work every time (assuming there
are no hardware problems, etc) regardless of the phases of the moon, or
anything else.

So if you like random crashing, data munging, and other fun debugging
headaches, feel free to continue as is. If you want consistancy, and error free
code, use an array when calling qsort.

~Kender

=====
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$ 
P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O 
M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@ 
b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
------END GEEK CODE BLOCK------

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

Reply via email to