June 22nd, 2013, 01:40 PM
passing a value from function ito fields of a structure
Is there a way of passing values gotten from a function into a fields of a struct?
Lets say you got a function that returns sum and square of some numbers.
How can I assign those values to the new made struct?
June 22nd, 2013, 02:31 PM
Re: passing a value from function ito fields of a structure
Like in this example
This gives more info about structs which you might find useful
int sum(int a, int b)
return a + b;
int sqr(int a)
return a * a;
st.sum_from_func = sum(1, 2);
st.square_from_func = sqr(2);
Last edited by 2kaud; June 22nd, 2013 at 02:33 PM.
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!