• Tidak ada hasil yang ditemukan

Fundamentals of Programming

N/A
N/A
Protected

Academic year: 2024

Membagikan "Fundamentals of Programming"

Copied!
60
0
0

Teks penuh

(1)

Fundamentals of Programming

lecture 19

Pointers and Arrays,

Pointer Arithmetic

(2)

Array arguments are addresses

(3)

Array arguments vs Pointers

(4)

Array arguments vs Pointers

(5)

The following are equivalent

(6)

Arrays vs. Pointers

(7)

Arrays vs. Pointers

(8)

Arrays vs. Pointers

(9)

Arrays vs. Pointers

(10)

Arrays vs. Pointers

(11)

Arrays vs. Pointers

(12)

Arrays vs. Pointers

(13)

Arrays vs. Pointers

(14)

Arrays vs. Pointers

(15)

Arrays vs. Pointers

pointerarray7.c

(16)

Arrays vs. Pointers

(17)

Arrays vs. Pointers

(18)

Arrays vs. Pointers

(19)

Arrays vs. Pointers

(20)

Arrays vs. Pointers

(21)

Arrays vs. Pointers

(22)

Arrays vs. Pointers

(23)

Arrays vs. Pointers

pointerarray10.c pointers and arrays are the same right?

(24)

Arrays vs. Pointers

(25)

Arrays vs. Pointers

(26)

Arrays vs. Pointers

(27)

Arrays vs. Pointers

pointerarray11.c

(28)

Arrays vs. Pointers

pointerarray11.c

somehow, similar to int * const p;

(29)

Arrays vs. Pointers: size

(30)

Arrays vs. Pointers: size

(31)

Arrays vs. Pointers: size

pointerarray12.c

Addressed are stored in 8 bytes in

(32)

Arrays vs. Pointers: size

(33)

Arrays vs. Pointers: size

pointerarray12.c

Addressed are stored in 4 bytes in

(34)

Array arguments: size

(35)

Array arguments: size

(36)

Array arguments: size

pointerarray14.c

(37)

Pointer Arithmetic

(38)

Pointer Arithmetic

(39)

Pointer Arithmetic

pointerarithmetic1.c

(40)

Pointer arithmetic: pointer + integer

(41)

Pointer arithmetic: pointer + integer

pointerarithmetic2.c

4 3 2 1

2012 2008 2004 a = 2000

5 Memory

2016

(42)

Pointer arithmetic: pointer + integer

pointerarithmetic2.c

4 3 2 1

2012 2008 2004 a = 2000

Memory

2016 p = 2000

(43)

Pointer arithmetic: pointer + integer

pointerarithmetic2.c

4 3 2 1

2012 2008 2004 a = 2000

5 Memory

2016 p = 2000

p+1 = ?

p+2 = ?

(44)

Pointer arithmetic: pointer + integer

pointerarithmetic2.c

4 3 2 1

2012 2008 2004 a = 2000

Memory

2016 p = 2000

p+1 = 2004

p+2 = 2008

(45)

Pointer arithmetic: pointer + integer

pointerarithmetic2.c

4 3 2 1

2012 2008 2004 a = 2000

5 Memory

2016 p = 2000

p+1 = 2004

p+2 = 2008

(46)

The precedence table

*p+i

*(p+i)

(47)

pointer definition

(48)

pointer definition

(49)

pointer definition

(50)

pointer definition

(51)

pointer arithmetic & arrays

(52)

pointer arithmetic & arrays

pointerarithmetic5.c pointerarithmetic6.c

(53)

pointer arithmetic & arrays

a[0] *a a[i] *(a+i)

pointerarithmetic5.c pointerarithmetic6.c

(54)

pointer arithmetic & arrays

(55)

pointer arithmetic & arrays

(56)

pointerarithmetic8.c

(57)

Exercise

(58)

Exercise

(59)

Subtracting two pointers

int a[10];

int *p = a;

int *q = &a[6];

int i = q - p;

(60)

Subtracting two pointers

int a[10];

int *p = a;

int *q = &a[6];

int i = q - p;

Referensi

Dokumen terkait

¾ Students are able to explain the difference between One-Dimensional Arrays and other data types ¾ Students are able to compose a program to solve a problem that has data type

( ∗ 1) Write declarations for the following: a function taking arguments of type pointer to charac- ter and reference to integer and returning no value; a pointer to such a function;

The implicit conversion of an array name to a pointer to the initial element of the array is exten- sively used in function calls in C-style code.. The snag is that it is impossible

At this stage the process is carried out using the PHP program where the sorting of the data is sorted using the PHP programming language which provides a sort function to sort

Overall, spherical sparse arrays are good candidates for therapeutic transducer design, but array size, sparsity, element count, and element arrangement offer tradeoffs between cost,

CLO1, CLO2 Class Test, Assignmen t, Final Week-7 Lesson 12 [3 Hours] Review and Exercises up to Array None Mid Term Exam Week-8 Lesson 13 & 14 [3 Hours] Pointer Expressions,

3.2.2 The Root Definition The root definition RD for this study based on the PQR formula is teaching students the fundamentals of programming within the given time frame by changing

Object -oriented programming languages support additional features, with the following most important ones:  Abstract data type definitions are used to define properties of classes of