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'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'