01-18-2009
first ,you don't use the int ID int fuction foo,
second ,you malloc fname and lname in a fuction(although they are pointers ,but you know ,you can't get a val from a fuction by pass it a pointer ) , int the main ,you don initial them, so the result is random
Last edited by aobai; 01-18-2009 at 12:42 AM..
10 More Discussions You Might Find Interesting
1. Programming
I have two string returning function in ESQL/C
char *segment_name(lbuffer)
char *lbuffer;
{.....
and
char *get_bpdvalue(f_name)
char *f_name;
{......
both declared above main()
char *get_bpdvalue();
char *segment_name();
my problem is segment_name works on sprintf and strcpy... (5 Replies)
Discussion started by: jisc
5 Replies
2. Shell Programming and Scripting
Hi all,
I am very new to BASH shell programming. I need to return an integer from a function to the caller function. I did this:
but it keeps giving me wrong return:
Can someone help me out here, please?
Thanks (2 Replies)
Discussion started by: alirezan
2 Replies
3. Shell Programming and Scripting
Hi All
In my script, I can call on several functions. I have a logging function that is called by any of these functions. What I would like is some way of identifying which function I am using and pass this to the log function as some parameter.
Is there some built in command or way of... (3 Replies)
Discussion started by: kingpin2502
3 Replies
4. Shell Programming and Scripting
i have an oracle function which returns two values, one is the error message if the function encounters anything and another one which returns a number
i need to capture both
and pass it on to unix shell script
how to do it (2 Replies)
Discussion started by: trichyselva
2 Replies
5. Programming
Hi guys.
how a functions such fdopen, ... can return pointer?
are these functions use static memory(variables)? (6 Replies)
Discussion started by: majid.merkava
6 Replies
6. Programming
I know multiple values can be returned from a function in C like this:
char **read_file ( char * , unsigned long int * );//this is the function prototypeunsigned long int number_of_words = 0;//variable defined in main() and initialized to 0words_from_dictionary = read_file ( "dictionary.dit" ,... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies
7. Shell Programming and Scripting
I've been trying to write a command-line function to grab a website's MX records and their ip addresses. The code below works with domains that only have one MX record:
function kmx { mx=`host -t MX $1 | awk '{ print $7 }'`;
ip=`host $mx | sed '/IPv6/d;/handled/d' | awk '{ print $4 }'`; ... (8 Replies)
Discussion started by: Azrael
8 Replies
8. Shell Programming and Scripting
Hi
I am pretty confused in returning and capturing multiple values
i have defined a function which should return values "total, difference"
i have used as
#!/usr/bin/ksh
calc()
{
total=$1+$2
echo "$total"
diff=$2-$1
echo "$diff"
}
I have invoked this function as
calc 5 8
Now i... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
9. Shell Programming and Scripting
Hi
I have a code as the following
#!/usr/bin/ksh
set -x
row()
{
a=$1
b=$2
c=$(($a + $b))
d=$(($a * $b))
echo $a $b
}
e=`row 2 3`
set $e
echo "The value of c is $c"
echo "The value of d is $d"
My requirement is I need to pass two arguments to a function and return two values... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies
10. Shell Programming and Scripting
Hi,
I have a small part of a project which is done as a bash script. bash was selected as an portability issue that works out of the box. In this script I have an exec shell-function, a wrapper around arbitrary commands. I want to have STDOUT, as an addon STDERR and the EXIT-CODE of a specified... (5 Replies)
Discussion started by: stomp
5 Replies
LEARN ABOUT LINUX
malloc_get_state
MALLOC_GET_STATE(3) Linux Programmer's Manual MALLOC_GET_STATE(3)
NAME
malloc_get_state, malloc_set_state - record and restore state of malloc implementation
SYNOPSIS
#include <malloc.h>
void* malloc_get_state(void);
int malloc_set_state(void *state);
DESCRIPTION
The malloc_get_state() function records the current state of all malloc(3) internal bookkeeping variables (but not the actual contents of
the heap or the state of malloc_hook(3) functions pointers). The state is recorded in a system-dependent opaque data structure dynamically
allocated via malloc(3), and a pointer to that data structure is returned as the function result. (It is the caller's responsibility to
free(3) this memory.)
The malloc_set_state() function restores the state of all malloc(3) internal bookkeeping variables to the values recorded in the opaque
data structure pointed to by state.
RETURN VALUE
On success, malloc_get_state() returns a pointer to a newly allocated opaque data structure. On error (for example, memory could not be
allocated for the data structure), malloc_get_state() returns NULL.
On success, malloc_set_state() returns 0. If the implementation detects that state does not point to a correctly formed data structure,
malloc_set_state() returns -1. If the implementation detects that the version of the data structure referred to by state is a more recent
version than this implementation knows about, malloc_set_state() returns -2.
CONFORMING TO
These functions are GNU extensions.
NOTES
These functions are useful when using this malloc(3) implementation as part of a shared library, and the heap contents are saved/restored
via some other method. This technique is used by GNU Emacs to implement its "dumping" function.
Hook function pointers are never saved or restored by these functions, with two exceptions: if malloc checking (see mallopt(3)) was in use
when malloc_get_state() was called, then malloc_set_state() resets malloc checking hooks if possible; if malloc checking was not in use in
the recorded state, but the caller has requested malloc checking, then the hooks are reset to 0.
SEE ALSO
malloc(3), mallopt(3)
GNU
2014-06-13 MALLOC_GET_STATE(3)