qsort(3) Library Functions Manual qsort(3)NAME
qsort - Sorts a table in place
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <stdlib.h>
void qsort(
void *base,
size_t nmemb,
size_t size,
int (*compar) (const void *, const void *));
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
qsort(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Points to the first entry in the table. Specifies the number of entries in the table. Specifies the size in bytes of each table entry.
Points to the user-specified function to be used to compare pairs of table elements. The comparison function will be called with two
parameters that point to the two elements to be compared. The comparison function must return an integer less than, equal to, or greater
than zero, depending on whether the first element in the comparison is considered less than, equal to, or greater than the second element.
DESCRIPTION
The qsort() function sorts a table having a specified number of entries. The contents of the table are sorted in ascending order according
to a user-specified comparison function (the strcmp() function, for example).
NOTES
The comparison function need not compare every byte, so arbitrary data may be contained in the elements in addition to the values being
compared.
When two members compare equal, their order in the sorted array is indeterminate.
RELATED INFORMATION
Functions: bsearch(3), lsearch(3)
Standards: standards(5) delim off
qsort(3)
Check Out this Related Man Page
bsearch(3) Library Functions Manual bsearch(3)NAME
bsearch - Performs a binary search
LIBRARY
Standard C Library (libc)
SYNOPSIS
#include <stdlib.h>
void *bsearch(
const void *key,
const void *base,
size_t nmemb,
size_t size,
int (*compar)(const void *, const void *));
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
bsearch(): XSH5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Target of search. Points to the initial object in the array. Specifies the number of elements in the array. Specifies the byte size of
each element of the array. Points to the comparison function, which is called with two parameters that point to the key object and to an
array member, in that order.
DESCRIPTION
The bsearch() function does a binary search and returns a pointer in an array that indicates where an object is found.
The compar comparison function is called with two parameters that point to objects that are compared during the search. This function
returns an integer less than, equal to, or greater than 0 (zero) depending whether the object pointed to by the key parameter is considered
to be less than, equal to, or greater than the array element.
NOTES
[Tru64 UNIX] The bsearch() function is reentrant, but care should be taken to ensure that the function supplied as argument compar is also
reentrant.
RETURN VALUES
Upon successful completion, the bsearch() function returns a pointer to a matching object in the array. A NULL is returned when no match
is found. When two or more objects compare equally, the returned object is unspecified.
RELATED INFORMATION
Functions: hsearch(3), lsearch(3), qsort(3), tsearch(3)
Standards: standards(5) delim off
bsearch(3)
hi all,
i have file as below:
N000150100B00|1
N000150100B00|3
E0P2C42100000|2
E0P2C42100000|3
N000150100B00|2
N000150100B00|4
E0P2C42100000|3
E0P2C42100000|3
E0P2C42100000|6
now i want to compare 1st field of all rows with all other row's first field
and if they are same then i... (2 Replies)
hi
I have 2 files to comapre ,in file a sible column it is numbers,in file b2 numbers and other values with coma separated.
i want compare numbers in file a with file b,and the out put put should be in C with numbers in both file a and b along with other columns of file b.
i used folowing... (7 Replies)
Dear linux experts,
I'd like to ask for your support, I've read some posts in this forum about files comparison but haven't found what I'm looking for. I need to create a sequential script to compare row-by-row one file with 34 similar files but without success so far. This is what I get:
... (2 Replies)
Hello,
I am trying to compare two variables, which both have a word stored in it.
The code I am using is. Please tell me which one of these is correct.Or please tell me the correct syntax.
Thankyou
if then
if then
if then
if then
if then
None of them seems to work... (3 Replies)
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)
I 've a question regarding which points should be considered to compare 2 different linux distros say RedHat & Ubuntu. for a production environment
non-db applications ... any help will be appreciated .. (1 Reply)
hi guys
i need a program that can compare a value read from a com-port and one from the terminal.
can somebody help me???
using linux kernel 2.6.14-M5
can only use standard function in sh and bash... (5 Replies)
Experts,
I am looking to compare elements of 2 array using perl. Below is not the actual code but logic wise something like this.
my $version = "MYSQlcl-5.2.4-264.x86_64"; <-- split this word into array as (5 2 4 264) ( which is to extract only the version number from the package name)
my... (1 Reply)
Hi all,
I want to compare two files with same number of rows and columns with records in same order.
Just want to highlight the differences in the column values if any.
file A
1,kolkata,19,ab
2,delhi,89,cd
3,bangalore,56,ef
file2:
1,kolkata,21,ab
2,mumbai,89,gh
3,bangalore,11,kl... (9 Replies)
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)