{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

(16) Pointers Sorting (Sina)

# (16) Pointers Sorting (Sina) - Pointers and Sorting Sina...

This preview shows pages 1–10. Sign up to view the full content.

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Pointers and Sorting Sina Meraji Fall 2009 Hello Pointers! int main() { /*This program is supposed to swap x and y*/ int temp, x = 5, y = 10; int * px, * py; px = & x; py = & y; temp = * px; * px = * py; * py = temp; } 10 5 px = 18AD71334 py = C63F9112 * px = x = 5 * py = y = 10 Pointers and Arrays 1 Byte An array of integers int my_array [ 3 ] 1 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 1 1 1 1 address & my_array = 100 my_array holds the address of its first element 1 Byte An array of integers int my_array [ 3 ] 1 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 1 1 1 1 address my_array holds the address of its first element & my_array [ 0 ] = 100 & my_array [ 1 ] = 104 & my_array [ 2 ] = 108 1 Byte An alternative way int * ptr ptr = & my_array [ 0 ] 1 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 1 1 1 1 address ptr + 1 adds one block with the size of ptr type ptr = 100 ptr + 1 = 104 ptr + 2 = 108 Pointers and Arrays ¡ Pointers are very closely linked to arrays in C ¡ There is a duality between an array, which is a clock of memory cells, and a pointer to a memory location ¡ The array is a pointer to the first of these cells Pointers and Arrays A note on parameters ¡ We want to pass an array as a parameter to a...
View Full Document

{[ snackBarMessage ]}

### Page1 / 40

(16) Pointers Sorting (Sina) - Pointers and Sorting Sina...

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

View Full Document
Ask a homework question - tutors are online