|
I think that depends on what you mean by "oblivious." As Paul said, a pointer simply points to a hunk of memory, it has no knowledge of what's at that memory location, nor does it care. However, good coding practice, IMHO, would demand that you not be oblivious to what's at that location. For example I wouldn't do the following: ------BAD------ TheString string; TheInt int; TheFloat float; ThePointer pointer; TheString = "asdsad"; ThePointer = addressof(TheString); DoSomething(ThePointer); TheInt = 7; ThePointer = addressof(TheInt); DoSomethingDifferent(ThePointer); TheFloat = 899.332; ThePointer = addressof(TheFloat); DoSomethingElse(ThePointer); ------END BAD------ But I would rather see the following: ------GOOD------ TheString string; TheStringPointer pointer; TheInt int; TheIntPointer pointer; TheFloat float; TheFloatPointer pointer; TheString = "asdsad"; TheStringPointer = addressof(TheString); DoSomething(TheStringPointer); TheInt = 7; TheIntPointer = addressof(TheInt); DoSomethingDifferent(TheIntPointer); TheFloat = 899.332; TheFloatPointer = addressof(TheFloat); DoSomethingElse(TheFloatPointer); ------END GOOD------ In the second example the deceloper "knows" what the pointer points to because he's declared a pointer for a specific purpose and uses it for such. Just my 2 cents worth. -Walden ------------ Walden H Leverich III President Tech Software (516) 627-3800 x11 (208) 692-3308 eFax WaldenL@TechSoftInc.com http://www.TechSoftInc.com Quiquid latine dictum sit altum viditur. (Whatever is said in Latin seems profound.) -----Original Message----- From: Sunil [mailto:sunil_ramakumar@USSWI.com] Sent: Thursday, May 30, 2002 10:48 To: rpg400-l@midrange.com Subject: Re: **Pointers Hai, In that case when we code can we be oblivious of wheather a pointer points to a string or a char or a int. Sunil ----- Original Message ----- From: "Nicolay, Paul" <paul_nicolay@merck.com> To: <rpg400-l@midrange.com> Sent: Thursday, May 30, 2002 8:01 PM Subject: RE: **Pointers Hi, I'll try to be short... a pointer by itself is nothing more than a datatype, and actually holds the address of a memory location. What is stored at that memory location is unknown by the pointer itself. In C however, when you write *char... it means a pointer to a character array (in other words a string). Since C doesn't have the concept of a string like in RPG, they usually null terminate it, meaning that x number of bytes further than the memory address a hex null is stored to indicate the end of the string. Kind regards, Paul -----Original Message----- From: Sunil [mailto:sunil_ramakumar@USSWI.com] Sent: 30 May, 2002 16:34 To: rpg400-l@midrange.com Subject: **Pointers Hai, I am a bit new to pointers and the related stuff in RPG. I am confused when some authors say *char, string* etc. As far as my understanding goes you cant define a datatype for a pointer ( infact pointer itself is a datatype, right!!). Am I right? If I am what does *char mean? Does it simply refer to the data that we know must is stored in the memory space pointed by the pointer? Regards Sunil -- _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. ---------------------------------------------------------------------------- -- Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it. ============================================================================ == _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.