|
Mark, The problem is that you are returning a pointer to a data structure that is defined locally to the subprocedure, the data structure goes away when the subprocedure ends. You mainline code now has a pointer to memory that is available for the operating system to reuse! Thus, when you call another subprocedure the memory gets allocated to a field defined locally in that subprocedure. You need to define the field globally if it is to exist after the call to the subprocedure, or you can define it as 'static' in the subprocedure. A method to accomplish this is to define the data structure globally and pass it as a parameter to the subprocedure that fills it with data. And, if you use the default of passing that parameter by reference then it really only passes the address (pointer) to it anyway when the call is made. Scott Mildenberger
As an Amazon Associate we earn from qualifying purchases.
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.