Article View: att.lang.c++
Article #68Losing my pointer
From: New C Programmer
Date: Sun, 20 Feb 2000 00:00
Date: Sun, 20 Feb 2000 00:00
62 lines
1986 bytes
1986 bytes
I am trying to change the value of a pointer in a function. I successfully
change it in the function but when I get back to the calling function it
returns to the original value.
This is the calling function from llist.cpp (a test harness)
if ( my_llist.i_traverse( from_where, data_ptr ))
{
element = data_ptr->storage;
cout << " Traversed node contained: " << element << ". ";
}else cout << "\nThere was an error, try again.\n";
break;
This is the called function from llist.h.
// *************************************************
// traverse a list, if from_where = 1 then increment data_ptr by one node
else return
// list head in data_ptr.
// *************************************************
BOOLEAN llist::i_traverse ( BOOLEAN from_where, NODE *data_ptr )
{
int pos = 0;
int count;
NODE *top_ptr = LinkedList;
NODE *temp_ptr = LinkedList;
// NODE *temp_ptr2 = *data_ptr;
count = llist::i_size();
if ( count <= 0 )
{
return ( FALSE ); /* position out of range */
}
if (data_ptr == NULL)
{
data_ptr = LinkedList;
return ( TRUE );
}
if ( from_where == 0 )
{
data_ptr = LinkedList;
return ( TRUE );
}
if ( data_ptr->next != NULL )
{
data_ptr = temp_ptr->next;
return ( TRUE );
}
else
{
return ( FALSE );
}
}
Thanks,
Steve
Technical Details
Message-ID:
<88q96p$d3f$1@bob.news.rcn.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,cce8f20ebac583c6,start X-Google-Attributes: gid10d4ba,public From: "New C Programmer" <s_joanis@siebe-ene.com> Subject: Losing my pointer Date: 2000/02/20 Message-ID: <88q96p$d3f$1@bob.news.rcn.net> X-Deja-AN: 587770472 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@rcn.com X-Trace: vkdj6Atd0phzdyrK4X0mWp9QnavqIGzxAAuLLCzbVqM= Organization: Siebe-ENE X-MSMail-Priority: Normal Reply-To: "New C Programmer" <s_joanis@siebe-ene.com> NNTP-Posting-Date: 21 Feb 2000 02:51:05 GMT Newsgroups: att.lang.c++