Slinked_list * list;
// creating list
Slinked_list *node = list;
for ( int i = 0; i < 8; i++ )
node->next = new Slinked_list; // You'll have to call delete in a similar way to free the memory
node->next = NULL; // last one
// accessing nth element
Slinked_list *t = list;
for ( int i = 0; i < n; i++ )
{
if ( t == NULL )
// there's no nth element
}
if ( did not find NULL )
t is the nth element
Slinked_list* iter = &a// so its pointing to the "head" of the list
for(int i=0; i<3; i++)
if( iter->next )
iter = iter->next;
else
{
cout << "Oops! There are less than 4 nodes in the list.";
break;
}
if( iter )// it got to the 4th element
cout << "The value of iVar in the 4th node = " << iter->iVar;
Your use of automatic variables for nodes should work though it's unconventional.