05-07-2008
ya sure ..a very simple example
my sample.c file is given below:
# include <stdio.h>
void pline(void);
main(int argc,char *argv[])
{
int i,j;
printf("Wow Entered main\n");
i=strcmp(argv[0],"pline"); /*just to test*/
j=strcmp(argv[1],"pline"); /*just to test*/
printf("i=%d \n j=%d\n",i,j);
if(strcmp(argv[1],"pline") == 0)
{
pline();
printf("done\n");
}
}
void pline(void)
{
int i;
for(i=1;i<5;i++)
printf("Test \n");
printf("\n");
}
No call the function from a 1.pl file .. this is my requirement
i guess we need to get the executable of sample.c after compiling. this too is done and executable is generated.
Thanks
10 More Discussions You Might Find Interesting
1. Programming
hi,
I just started to work on unix,
I was wondering if it is possible to call a c++ function from a script.
now, i don't mean starting a program, i mean dynamicaly calling a funtion (like working with a dll)
thanks (3 Replies)
Discussion started by: Lebamb
3 Replies
2. Shell Programming and Scripting
Hi folks,
I'm just running through an oreilly korn shell book but have witnessed an output difference on my own unix machine and the output provided in the book. Can anyone help?
create a script called ascript as follows:
function afunc {
print in function $0: $1 $2
var1="in... (16 Replies)
Discussion started by: beckett
16 Replies
3. UNIX for Dummies Questions & Answers
i have a function defined in one ksh (ksh 1)
i want to use that function in another ksh (ksh 2)
i am using
. $<directoryname>/<ksh name>
i am calling the function defined in ksh 1 in ksh 2
i want the returnstatus from the above operation
but it is not executing the function
what i... (1 Reply)
Discussion started by: trichyselva
1 Replies
4. Shell Programming and Scripting
Hi,
I have searched the forum for the query, But i didnt find an exact answer.
I have a script(1.sh) and a c program(sample.c)
sample.c contains many function definitions.( run(), find(), add() etc).
I want to call functions in sample.c from 1.sh and use the return value in 1.sh... (3 Replies)
Discussion started by: jisha
3 Replies
5. Shell Programming and Scripting
Dear Sir/Madam,
I use the following way to call the oracle stored procedure in a perl script, but I do not know how to call a oracle function by the following way ?
# ARGV is the oracle stored procedure name with parameters
$str = "sqlplus -s <<-eof \n" .
"$db_login... (0 Replies)
Discussion started by: ili
0 Replies
6. Shell Programming and Scripting
This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:
function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies
7. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies
8. Shell Programming and Scripting
I have two variables. I need to call them using the same function
my $dat1 ="abc";
my $dat2 ="def";
my $check;
filecheck($dat1,$dat2);
sub filecheck($)
{
$check = shift;
print "first name is $check\n";
}
print "this is fine\n";
sub filecheck($)
{
$check = shift;
print "second... (2 Replies)
Discussion started by: irudayaraj
2 Replies
9. Shell Programming and Scripting
I would like to call functions from another bash script. How can I do it? Some code More code (11 Replies)
Discussion started by: kristinu
11 Replies
10. Shell Programming and Scripting
I have a function which does awk proceessing
sub mergeDescription {
system (q@awk -F'~' '
NR == FNR {
A = $1
B = $2
C = $0
next
}
{
n = split ( C, V, "~" )
if... (3 Replies)
Discussion started by: crypto87
3 Replies
LEARN ABOUT CENTOS
qsort_r
QSORT(3) Linux Programmer's Manual QSORT(3)
NAME
qsort, qsort_r - sort an array
SYNOPSIS
#include <stdlib.h>
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort_r(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *, void *),
void *arg);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
qsort_r(): _GNU_SOURCE
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.
The qsort_r() function is identical to qsort() except that the comparison function compar takes a third argument. A pointer is passed to
the comparison function via arg. In this way, the comparison function does not need to use global variables to pass through arbitrary
arguments, and is therefore reentrant and safe to use in threads.
RETURN VALUE
The qsort() and qsort_r() functions return no value.
VERSIONS
qsort_r() was added to glibc in version 2.8.
CONFORMING TO
The qsort() function conforms to SVr4, 4.3BSD, C89, C99.
NOTES
Library routines suitable for use as the compar argument to qsort() 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(char *), 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.53 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/.
2012-03-08 QSORT(3)