transferring a structrure

Hi again, I would like to ask, how can I transfer a structure from a subfunction to another function. As example, I would like to assign three members with different variables and value in a structure. Then those values are obtained from a subfunction. But how can I transfer back those values into the structure using this method?
You can pass by reference, so the passed object itself will be modified
eg:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct s { int i; }

void f2 ( s &obj )
{
    obj.i = 5;
}


void f1 ()
{
    s x;
    f2 ( x );
    // Now x.i == 5
}
Topic archived. No new replies allowed.