Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basics -pointing to variables

Status
Not open for further replies.

sunaj

Technical User
Feb 13, 2001
1,474
DK
Hi,

I'm trying to get this C code working that I got, but knowing little of C I'm failing misserably. A little help from you can hopefully get me on the right track.
This one is probably simple...

A procedure takes a number of parameters, some of them are the return values and they are declared as e.g. 'float *y'.
How do I declare & pass a variable to return from such a sub?
I've made an example that illustrates (this code generates an error in line '*y=(float) 2'. Remember that I can't change sub1):

-----------------------------------------------
#include <iostream.h>

void sub1(float *y) {
*y=(float) 2;
}

void main() {
float *x;
sub1(x);
cout << sub1;
}
----------------------------------------------- Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I found out myself - thx for your attention anyway... Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top