Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

qsort(3c) [hpux man page]

qsort(3C)																 qsort(3C)

NAME
qsort() - quicksort SYNOPSIS
DESCRIPTION
is an implementation of the quicksort algorithm. It sorts a table of data in place. base Pointer to the element at the base of the table. nel Number of elements in the table. size Size of each element in the table. compar Name of the comparison function, which is called with two arguments that point to the elements being compared. The function passed as compar must return an integer less than, equal to, or greater than zero, according to whether its first argument is to be considered less than, equal to, or greater than the second. uses this same return convention (see string(3C)). NOTES
The pointer to the base of the table should be of type pointer-to-element, and cast to type pointer-to-void. The comparison function need not compare every byte; thus, arbitrary data can be contained in the elements in addition to the values being compared. The order in the output of two items which compare as equal is unpredictable. WARNINGS
If size is zero, a divide-by-zero error might be generated. SEE ALSO
sort(1), bsearch(3C), lsearch(3C), string(3C), thread_safety(5). STANDARDS CONFORMANCE
qsort(3C)

Check Out this Related Man Page

lsearch(3C)															       lsearch(3C)

NAME
lsearch(), lfind() - linear search and update SYNOPSIS
DESCRIPTION
is a linear search routine generalized from Knuth (6.1) Algorithm S. It returns a pointer into a table indicating where a datum may be found. If the datum does not occur, it is added at the end of the table. key Points to the datum to be sought in the table. base Points to the first element in the table. nelp Points to an integer containing the current number of elements in the table. The integer is incremented if the datum is added to the table. compar Name of the comparison function which the user must supply for example). It is called with two argu- ments that point to the elements being compared. The function must return zero if the elements are equal and non-zero otherwise. Same as except that if the datum is not found, it is not added to the table. Instead, a NULL pointer is returned. Notes The pointers to the key and the element at the base of the table should be of type pointer-to-element, and cast to type pointer-to-charac- ter. The comparison function need not compare every byte, so arbitrary data may be contained in the elements in addition to the values being compared. Although declared as type pointer-to-character, the value returned should be cast into type pointer-to-element. EXAMPLES
This code fragment reads in <= strings of length <= and stores them in a table, eliminating duplicates. ... ... RETURN VALUE
If the searched-for datum is found, both and return a pointer to it. Otherwise, returns NULL and returns a pointer to the newly added ele- ment. WARNINGS
Undefined results can occur if there is not enough room in the table to add a new item. SEE ALSO
bsearch(3C), hsearch(3C), tsearch(3C), thread_safety(5). STANDARDS CONFORMANCE
lsearch(3C)
Man Page

6 More Discussions You Might Find Interesting

1. Programming

comparison between pointer and integer

I received a warning when I tried to compile my program that said: warning: comparison between pointer and integer Could you please explain to me what this means, and in what ways I could possibly fix this? Thanks for your help! (2 Replies)
Discussion started by: sjung10
2 Replies

2. Shell Programming and Scripting

fail on comparison

Hi Am having 2 files. I have one data file. before inserting in to the table am taking cout of the data file and store as data 1. After insert in to the table and am taking the count from the table and store as data2. If i try to compare those values If then echo "data match"... (5 Replies)
Discussion started by: bobprabhu
5 Replies

3. Shell Programming and Scripting

String comparison problem

Hi, can someone please help me!!! urgent! I have a strange issue here. I grep for 2 strings from a txt files and compare the string value. Though the string values are the same, they are compared as different values. Please help Case-1 -------- Here I grep for 2 different field values... (3 Replies)
Discussion started by: vani123
3 Replies

4. Programming

Qsort Error

I am looking at a small C program that uses qsort to sort an array of strings and an error occurs when it passes qsort a function to compare integers instead of strings. Why can't the compiler catch this? And what would happen if I was using qsort to sort integers and accidentally pass the string... (3 Replies)
Discussion started by: totoro125
3 Replies

5. Shell Programming and Scripting

DB2 in awk

Hi, I want to retrieve the base table name for a table and replace the table with the view name in the file. I was trying to retrieve the base with the below db2 command but i am getting "1" as return value. Could you anyone please assist ? Table_name=system("db2 -x... (4 Replies)
Discussion started by: Nandy
4 Replies

6. Shell Programming and Scripting

Compare 2 Strings

I have 2 values V_1_4_4_b1 and V_1_5_1_RC_b1. I would need to compare them and determine if the 1st value is greater, less or equal than the 2nd value. The result should need to have a return value. I have below code in bash function but it seems it is not comparing it correctly. Any help will... (8 Replies)
Discussion started by: aderamos12
8 Replies