× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Now you can ponder upon pointer to pointer to pointer to pointer which I frequently use in a middleware I wrote 20 years ago.
;-)

(Hint: It's a way of implementing C++ like classes in plain C. Now the debugger can handle it, but back then it failed after 3 pointer levels.)


/Joakim

-----Original Message-----
From: c400-l-bounces@xxxxxxxxxxxx [mailto:c400-l-bounces@xxxxxxxxxxxx] On Behalf Of Frank Kolmann
Sent: den 4 april 2014 10:14
To: c400-l
Subject: [C400-L] First C program

Hi Jevgeni

WOW, many thanks. I have updated the program.

Proves I still dont understand pointers, especially when to use a pointer to pointer.

I definitely did not want to use global. It was all I could get to work.



I did some more learning and I found this, here http://www.eskimo.com/~scs/cclass/int/sx8.html

'What are pointers to pointers good for, in practice? One use is returning pointers from functions,

'via pointer arguments rather than as the formal return value.



So the answer to my confusion is , when you want to return a pointer in a function arg,

you need a pointer to a pointer.



Frank





*Subject: Re: First C program

*From: Jevgeni Astanovski <Jevgeni.Astanovski@xxxxxxxxxxxxx>

*Date: Thu, 3 Apr 2014 11:17:52 +0000



If you want to open a file in a function and have its pointer available
in
main, you must pass pointer to pointer!

Something like this:



int main()

{

_RFILE *fp ;



openfile(&fp) ;

}



void openfile(_RFILE **fp)

{

*fp = _Ropen(...) ;

}



(Bad) Alternative is to have it defined as global variable.
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list To post a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/c400-l.


________________________________

Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini Sverige AB, a company registered in Sweden (number 556092-3053) whose registered office is at Gustavslundsvägen 131 Box 825 – S-161 24 Bromma.
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.