J
JhacK
I need to allocate a float array delegating the task to a subroutine .
The code I wrote is:
int foo(float *bar)
{
bar[0] = 3;
return 1;
}
int main (int argc, char* argv[])
{
float *bar;
int ret;
ret = foo(bar);
printf("%5.5f", bar[0]);
}
Why doesn't it work? How can I modify it, without using the return in
foo to retrieve the array (I want to use the return only to manage
errors)?
Thanks in advance,
J.
The code I wrote is:
int foo(float *bar)
{
bar[0] = 3;
return 1;
}
int main (int argc, char* argv[])
{
float *bar;
int ret;
ret = foo(bar);
printf("%5.5f", bar[0]);
}
Why doesn't it work? How can I modify it, without using the return in
foo to retrieve the array (I want to use the return only to manage
errors)?
Thanks in advance,
J.