× 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.



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.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.