03-21-2006
string returning function
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 while get_bpdvalue only works on strcpy and not sprintf
. someone told me that sprintf using string returning function usually has that bug.
ok, i can use strcpy first before i using sprintf but that would make my code longer. and i cant just accept the fact that ESQL/C has that kind of bug
. i hope someone can point me here in the right direction
, is there something i can do abou the function or its declaration to make it work in sprintf? thanks a lot...
10 More Discussions You Might Find Interesting
1. Programming
hi all,
my requirement is to create a thread by calling another function.
i.e i dont call pthread_create directly from main, but by calling another function (createThd - below ), from main.
Example:
void *thread_function(void *arg) { /* thread function */
int i;
rc =... (3 Replies)
Discussion started by: wolwy_pete
3 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. Programming
hi
how can I return multiple values from a C function. I tried the following:
#include <stdio.h>
void foo(int id, char *first_name, char *last_name)
{
/*
this is just an example to illustrate my problem... real code makes
use of the "id" parameter.
*/
first_name = (char... (8 Replies)
Discussion started by: Andrewkl
8 Replies
4. Shell Programming and Scripting
Hello all,
I would like to know if it is possible to return a the result of a boolean expression from a function like this
function()
{
# some code
return ||
}
and what will be the return value ?
Thank you for help. (6 Replies)
Discussion started by: dolphin06
6 Replies
5. 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
6. Programming
I am working on a C/Unix application from last 2 years which communicates with other systems using proprietary format of my client. We have a function written in C which returns integer, which is response from other system to the request message initiated by my system. This return value is then... (1 Reply)
Discussion started by: dpmore
1 Replies
7. 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
8. Programming
Hi,
If I have a code like this, what are the potential problems do you see?
const char* const retString() {
return "hello"; /* string literal */
}
My questions are:
a) Since the string literal which is already a constant read only data (cannot be... (4 Replies)
Discussion started by: royalibrahim
4 Replies
9. Programming
H friends,
As we know, a function returns a value and that value is saved somwhere. like
int Sum( int x, int y )
{
return x + y;
}
Total = Sum( 10, 20 );
The value 30 is saved in variable Total.
Now the question is, what int value does the function main return, and where is it... (5 Replies)
Discussion started by: gabam
5 Replies
10. Programming
Hi All,
I am using malloc function for allocating dynamic memory.
When I am using below code on Linux server its working fine, but When I am trying the same code on HP UNIX server its returning NULL.
below is a fragment of code in which it is giving problem.
tmp = (format_tree... (4 Replies)
Discussion started by: Taher Saifuddin
4 Replies
LEARN ABOUT SUNOS
fconvert
econvert(3C) Standard C Library Functions econvert(3C)
NAME
econvert, fconvert, gconvert, seconvert, sfconvert, sgconvert, qeconvert, qfconvert, qgconvert - output conversion
SYNOPSIS
#include <floatingpoint.h>
char *econvert(double value, int ndigit, int *decpt, int *sign, char *buf);
char *fconvert(double value, int ndigit, int *decpt, int *sign, char *buf);
char *gconvert(double value, int ndigit, int trailing, char *buf);
char *seconvert(single *value, int ndigit, int *decpt, int *sign, char *buf);
char *sfconvert(single *value, int ndigit, int *decpt, int *sign, char *buf);
char *sgconvert(single *value, int ndigit, int trailing, char *buf);
char *qeconvert(quadruple *value, int ndigit, int *decpt, int *sign, char *buf);
char *qfconvert(quadruple *value, int ndigit, int *decpt, int *sign, char *buf);
char *qgconvert(quadruple *value, int ndigit, int trailing, char *buf);
DESCRIPTION
The econvert() function converts the value to a null-terminated string of ndigit ASCII digits in buf and returns a pointer to buf. buf
should contain at least ndigit+1 characters. The position of the decimal point relative to the beginning of the string is stored indirectly
through decpt. Thus buf == "314" and *decpt == 1 corresponds to the numerical value 3.14, while buf == "314" and *decpt == -1 corresponds
to the numerical value .0314. If the sign of the result is negative, the word pointed to by sign is nonzero; otherwise it is zero. The
least significant digit is rounded.
The fconvert() function works much like econvert(), except that the correct digit has been rounded as if for sprintf(%w.nf) output with
n=ndigit digits to the right of the decimal point. ndigit can be negative to indicate rounding to the left of the decimal point. The return
value is a pointer to buf. buf should contain at least 310+max(0,ndigit) characters to accomodate any double-precision value.
The gconvert() function converts the value to a null-terminated ASCII string in buf and returns a pointer to buf. It produces ndigit sig-
nificant digits in fixed-decimal format, like sprintf(%w.nf), if possible, and otherwise in floating-decimal format, like sprintf(%w.ne);
in either case buf is ready for printing, with sign and exponent. The result corresponds to that obtained by
(void) sprintf(buf,``%w.ng'',value) ;
If trailing = 0, trailing zeros and a trailing point are suppressed, as in sprintf(%g). If trailing != 0, trailing zeros and a trailing
point are retained, as in sprintf(%#g).
The seconvert(), sfconvert(), and sgconvert() functions are single-precision versions of these functions, and are more efficient than the
corresponding double-precision versions. A pointer rather than the value itself is passed to avoid C's usual conversion of single-precision
arguments to double.
The qeconvert(), qfconvert(), and qgconvert() functions are quadruple-precision versions of these functions. The qfconvert() function can
overflow the decimal_record field ds if value is too large. In that case, buf[0] is set to zero.
The ecvt(), fcvt() and gcvt() functions are versions of econvert(), fconvert(), and gconvert(), respectively, that are documented on the
ecvt(3C) manual page. They constitute the default implementation of these functions and conform to the X/Open CAE Specification, System
Interfaces and Headers, Issue 4, Version 2.
USAGE
IEEE Infinities and NaNs are treated similarly by these functions. ``NaN'' is returned for NaN, and ``Inf'' or ``Infinity'' for Infinity.
The longer form is produced when ndigit >= 8.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
ecvt(3C),sprintf(3C), attributes(5)
SunOS 5.10 3 May 1999 econvert(3C)