Moving a part of a function into another function
<p>Here's a structure declaration for the nodes of a circular list:</p>

<pre><code>struct  Node
{
    int x; // info field
    struct Node *Next;
};
</code></pre>

<p>In <code>int main()</code> I have a loop that fills the list with numbers from 1 to 10:</p>

<pre><code>int main()
{

    Node *Head=NULL, *Tail=NULL; 
    int size = 0; 
    int info = 0; 

    for (int j = 0; j &lt; 10; j++) 
    { // for
        info++;
        size++; 
        Node *temp=new Node; 
        temp-&gt;Next=Head; 
        temp-&gt;x=info; 

        if (Head!=NULL)
        {
            Tail-&gt;Next = temp; 
            Tail=temp; 
        }

        else Head=Tail=temp;
    } // endfor
}
</code></pre>

<p>How to make a function that contains this loop and is called from <code>main()</code>?
Something like this:</p>

<pre><code>void Fill(struct Node *Head, struct Node *Tail, int &amp;x, int &amp;info)
{
  // &lt;function body&gt;
}

int main()
{
...
Fill(Head, Tail, x, info);
...
}
</code></pre>

<p>doesn't work :(</p>
