Hi,
How can I get the address of return value in function?
ex.
int function(int argument)
{
int *arg_address;
int *rtn_address;
arg_address = &argument;
rtn_address = ??; 11 3172
may be,you can do as following:
int ss(int i)
{
int *k = &i;
int *j = &i;
return (int)j; //this is a cast,becase j is a type of
int*
}
maybe,you can as following:
int ss(int i)
{
int *k = &i;
int *j = &i;
return (int)j; //this is a cast;
} ig*********@gmail.com wrote: Hi,
How can I get the address of return value in function?
It is not necessarily the case that the return value even has an
address. For sufficiently small types your compiler may choose to place
the return value in a register.
Alan
Hello, ig*********@gmail.com wrote: How can I get the address of return value in function?
Plain and simple answer, you can't. The location of the return value is
completely in the hands of the compiler, whether register or stack or
whatever. There are no syntactical means for influencing the return
value location or taking its address. This would be helpfull to print return value automatically (when object is destroyed).
I don't understand this, maybe you could provide a more complete
example, what you want to achieve, especially what it has to do with
destruction of an object.
Bernd
Getting an address of return value in function, why?
I think it's illegal, just silly.
The variable has been beyond its scope, but you want to use it by its'
pointer.
If i were you , I would never do that. ig*********@gmail.com wrote: Hi,
How can I get the address of return value in function?
Make the function take the address to store the return value into:
void f(int* result)
{
// here results is the address of the return value
*result = -1;
}
Well, it would be usefull for tracing. Destructor of object would print
return value automatically (when object goes out of scope - at the
return from function).
You can always do:
int f(int a)
{
int ret = 0;
int *ret_addr = &ret;
igor.....
do..u want to print..the address...of
variable...or....exact...locataion......of...retur n...value..location
I want to print return value automatically, without doing cout on every
return. This could be done if one has address of return variable or
address of temporary variable (above example), which is always set to
return value before actually returning. Then create an temporary
object, which prints this value at destruction.
Hope its clearer now. Should have give more info to start with... My
bad.
Regards,
Igor
I want to print return value automatically, without doing cout on every
return. This could be done if one has address of return variable or
address of temporary variable (above example), which is always set to
return value before actually returning. Then create an temporary
object, which prints this value at destruction.
Hope its clearer now. Should have give more info to start with... My
bad.
Regards,
Igor ig*********@gmail.com wrote: I want to print return value automatically, without doing cout on every return. This could be done if one has address of return variable or address of temporary variable (above example), which is always set to return value before actually returning.
How about a suitable #define RETURN?
As an added bonus, you can make it print only in debug mode.
HTH,
Michiel Salters This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pushker Pradhan |
last post by:
I have a function which should allocate memory, initialize it to some values
and return the address of the initialized memory to the calling function.
void getWaveletCoeffs(float *ld, float *hd,...
|
by: hasho |
last post by:
Why is "call by address" faster than "call by value"?
|
by: Adam Warner |
last post by:
Hi all,
In the code snippet below I successfully determine the address of val1:*
struct o val1=l_SYM_2B(&a).o;
print_aesthetic(&val1);
The structure o is heavyweight. I understand...
|
by: Brian Henry |
last post by:
I have a domain cluster with AD running, and I want to lookup a users email
address (exchange 2000 server is integrated with the AD system) so i can
email the user based on their user name. does...
|
by: kyle.tk |
last post by:
I am trying to write a function to convert an ipv4 address that is held
in the string char *ip to its long value equivalent. Here is what I
have right now, but I can't seem to get it to work.
...
|
by: Sourav |
last post by:
Suppose I have a code like this,
#include <stdio.h>
int *p;
void foo(int);
int main(void){
foo(3);
printf("%p %d\n",p,*p);
|
by: jdcrief |
last post by:
Using Visual C++2005 Expression Edition
Having trouble outputting the value referenced by the pointer and then
outputing the address of the pointer for the char. Any ideas would be
greatly...
|
by: !truth |
last post by:
Hi,
i feel confused about the following program, and it's works to get a
pointer-member's address.
#define NETDEV_ALIGN 32
#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
...
|
by: kang jia |
last post by:
hi
i am doing mailinglist currently. the code in my first page is like this :
:
<html>
<head>
<link rel="stylesheet" type="text/css" href="gallery.css" />
<script language="JavaScript">
...
|
by: karen.homersham |
last post by:
Just working through Apress Pro ASP NET.2.0.E Commerce in C Sharp. I
am having problems compiling the following:
using System;
using System.Collections.Generic;
using System.Text;
namespace...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |