Article View: att.lang.c++
Article #69Re: Losing my pointer
From: Eric
Date: Mon, 21 Feb 2000 00:00
Date: Mon, 21 Feb 2000 00:00
76 lines
2444 bytes
2444 bytes
Hi
While we (someone) work on your problem, have you been to
http://www.inquiry.com/techtips/cpp_pro/
there are lots of problems and answers
From Eric
New C Programmer <s_joanis@siebe-ene.com> wrote in message
news:88q96p$d3f$1@bob.news.rcn.net...
> 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:
<RTfs4.1009$ME2.8501@news.clear.net.nz>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<88q96p$d3f$1@bob.news.rcn.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,cce8f20ebac583c6 X-Google-Attributes: gid10d4ba,public From: "Eric" <rc@work.co.nz> Subject: Re: Losing my pointer Date: 2000/02/21 Message-ID: <RTfs4.1009$ME2.8501@news.clear.net.nz> X-Deja-AN: 588043305 References: <88q96p$d3f$1@bob.news.rcn.net> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@clear.net.nz X-Trace: news.clear.net.nz 951159409 203.97.54.183 (Tue, 22 Feb 2000 07:56:49 NZDT) Organization: CLEAR Net http://www.clear.net.nz/ X-MSMail-Priority: Normal Reply-To: "Eric" <rc@work.co.nz> NNTP-Posting-Date: Tue, 22 Feb 2000 07:56:49 NZDT Newsgroups: att.lang.c++