07-31-2011
Do you mind if I ask you another question?
Moderator's Comments:
|
|
Please, just ask it...
|
|
10 More Discussions You Might Find Interesting
1. Programming
I have a program which I wish to modify. It used to be run from the command line, but now I wish to change this so it can be used as a function.
The program has complex argument processing so I want to pass my paramters to as if it were being called by the OS as a program.
I have tried to... (2 Replies)
Discussion started by: mbb
2 Replies
2. UNIX for Dummies Questions & Answers
What is the function of rewind()? (2 Replies)
Discussion started by: tigerkin
2 Replies
3. Programming
Hi C experts,
I have the following code for adding command line option for a program
int main (argc, argv)
int argc;
char *argv;
{
char *mem_type; //memory type
char *name; //name of the memory
int addr; //address bits
int data; ... (5 Replies)
Discussion started by: return_user
5 Replies
4. Programming
Hello Friends,
I got stuck with fgets () & rewind() function .. Please need help..
Actually I am doing a like,
The function should read lines from a txt file until the function is called..
If the data from the txt file ends then it goes to the top and then again when the function is called... (1 Reply)
Discussion started by: user_prady
1 Replies
5. Shell Programming and Scripting
this is in one of my scripts...
if ($#argv == 0) then
echo 'blah bla'
exit 0
endif
I want it to be something like this...
if ($#argv == 0 OR $argv >=3)
echo 'blah bla'
exit 0
endif
so when the arguments are none, or greater than three I want this "if then" to take over. how? I... (5 Replies)
Discussion started by: ajp7701
5 Replies
6. UNIX for Dummies Questions & Answers
SCO openserver 5r5
I only have this available to me ...
To list the files...
cpio -itcvB < /dev/nrct0
To copy a file out
cpio -icvdBum filename < /dev/nrct0So cpio is to archive or "zip" files up??
and /dev/nrct0 is the tape drive ???
How can i list all the files inside... (2 Replies)
Discussion started by: khaos83_2000
2 Replies
7. Programming
Hi,
Can somehelp help how to list file in a dir? (5 Replies)
Discussion started by: Learnerabc
5 Replies
8. Programming
when i run my program, i have a parameter, that i want to set the value to another string
i am using
int main(int argc, char **argv) {
char my_str=argv;
printf("%s",my_str);
return 0;
}
and i get
Segmentation fault
ran using
./my_prog /usr/share/dict/words hello1
... (2 Replies)
Discussion started by: omega666
2 Replies
9. UNIX for Advanced & Expert Users
All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address).
I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies
10. UNIX for Dummies Questions & Answers
So i am trying to read in file
readFile <GivenFile> modFile
looking for a regular file under the directories in the GivenFile and print them out is my over all goal.
basically I am looking for anything that looks like a directory in the given file and printing it out.
Since I am trying to do... (2 Replies)
Discussion started by: squidGreen
2 Replies
LEARN ABOUT LINUX
qsort_r
QSORT(3) Linux Programmer's Manual QSORT(3)
NAME
qsort - sorts an array
SYNOPSIS
#include <stdlib.h>
void qsort(void *base, size_t nmemb, size_t size,
int(*compar)(const void *, const void *));
DESCRIPTION
The qsort() function sorts an array with nmemb elements of size size. The base argument points to the start of the array.
The contents of the array are sorted in ascending order according to a comparison function pointed to by compar, which is called with two
arguments that point to the objects being compared.
The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respec-
tively less than, equal to, or greater than the second. If two members compare as equal, their order in the sorted array is undefined.
RETURN VALUE
The qsort() function returns no value.
CONFORMING TO
SVr4, 4.3BSD, C89, C99.
NOTES
Library routines suitable for use as the compar argument include alphasort(3) and versionsort(3). To compare C strings, the comparison
function can call strcmp(3), as shown in the example below.
EXAMPLE
For one example of use, see the example under bsearch(3).
Another example is the following program, which sorts the strings given in its command-line arguments:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int
cmpstringp(const void *p1, const void *p2)
{
/* The actual arguments to this function are "pointers to
pointers to char", but strcmp(3) arguments are "pointers
to char", hence the following cast plus dereference */
return strcmp(* (char * const *) p1, * (char * const *) p2);
}
int
main(int argc, char *argv[])
{
int j;
if (argc < 2) {
fprintf(stderr, "Usage: %s <string>...
", argv[0]);
exit(EXIT_FAILURE);
}
qsort(&argv[1], argc - 1, sizeof(argv[1]), cmpstringp);
for (j = 1; j < argc; j++)
puts(argv[j]);
exit(EXIT_SUCCESS);
}
SEE ALSO
sort(1), alphasort(3), strcmp(3), versionsort(3)
COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
2009-09-15 QSORT(3)