LectureNinteen - Lecture 19 Pointers – Part I By Ghada...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 19 Pointers – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department The Hashemite University ٢ Outline ¡ Introduction. ¡ Pointer variables. ¡ Pointer operators. ¡ Calling functions by reference. ¡ Using const with pointers. The Hashemite University ٣ Introduction ¡ Pointers ¡ Powerful, but difficult to master. ¡ Simulate call-by-reference. ¡ Allow the creation of dynamic data structures that shrink and grow in size during run time, such as stacks, link lists, etc. ¡ Close relationship with arrays and strings. The Hashemite University ٤ Pointer Variable Declarations and Initialization I ¡ Pointer variables ¡ Contain memory addresses as their values ¡ Normal variables contain a specific value (direct reference) ¡ Pointers contain the address of a variable that has a specific value (indirect reference) ¡ Indirection ¡ Referencing a pointer value (accessing the contents of the memory location indicated by the address found inside the pointer). ¡ Pointer declarations ¡ * indicates that a variable is a pointer int *myPtr; declares a pointer to an int , a pointer of type int * ¡ Multiple pointers require multiple asterisks int *myPtr1, *myPtr2; The Hashemite University ٥ Pointer Variable Declarations and Initialization II ¡ Can declare pointers to any data type ¡ Pointers initialization ¡ Initialized to , NULL , or an address ¡ or NULL points to nothing The Hashemite University ٦ Pointer Operators I ¡ & (address operator) ¡ Returns the address of its operand ¡ It is different from the reference operator used in declaring reference variables....
View Full Document

Page1 / 15

LectureNinteen - Lecture 19 Pointers – Part I By Ghada...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online