Applications of Array Pointers (1A) Young Won Lim 11/22/18

Size: px
Start display at page:

Download "Applications of Array Pointers (1A) Young Won Lim 11/22/18"

Transcription

1 Appliations of Array Pointers (1A)

2 Copyright () Young W. Lim. Permission is granted to opy, distribute and/or modify this doument under the terms of the GNU Free Doumentation Liense, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Setions, no Front-Cover Texts, and no Bak-Cover Texts. A opy of the liense is inluded in the setion entitled "GNU Free Doumentation Liense". Please send orretions (or suggestions) to youngwlim@hotmail.om. This doument was produed by using LibreOffie.

3 Pointer to Multi-dimensional Arrays of Array Pointers 3

4 Integer pointer type (int (*)[4]) type an point only to int [4] type an int array name a pointer to a pointer (int **) *) (int *) a pointer to an int (int [4]) *) an int array name a pointer to a 1-d array (int (*)[4]) 1-d array pointer int [4] = (int [ ] int *) eah of these types points to an int type data of Array Pointers 4

5 Series of array pointers a type view a pointer to a 1-d array a pointer to a 1-d array a pointer to a 1-d array (int (*)[4]) (int (*)[4]) (int (*)[4]) 1-d array pointers (int [4]) *) the name of a 1-d int array (int [4]) *) the name of a 1-d int array (int [4]) *) the name of a 1-d int array of Array Pointers 5

6 Series of array pointers 1-d arrays a, b, int a[4]; int (*r); int b[4]; int [4]; (int *) r taking no memory loations a b a a a a b b b b assume that array a, b, and are ontiguous of Array Pointers 6

7 Series of array pointers array pointers p1, p2, p3 int (*p1)[4]; int (*p2)[4]; int (*p3)[4]; assignment p1 = &a p2 = &b p3 = & a pointer to a 1-d array a pointer to a 1-d array a pointer to a 1-d array 1-d array pointers p1 p2 p3 1-d arrays taking no memory loations a b a a a a b b b b assume that array p1, p2, and p3 are ontiguous assume that array a, b, and are ontiguous of Array Pointers 7

8 Series of array pointers 1-d arrays via p1, p2, p3 a pointer to a 1-d array a pointer to a 1-d array a pointer to a 1-d array equivalene (*p1) p1 a (*p2) p2 b (*p3) p3 p1 p2 p3 1-d array pointers taking no memory loations p1 p2 p3 p1 p1 p1 p1 p2 p2 p2 p2 assume that array a, b, and are ontiguous of Array Pointers 8

9 Series of array pointers a variable view int a[4]; int (*p1)[4]; int (*r); int b[4]; int (*p2)[4]; int [4]; int (*p3)[4]; assignment p1 = &a p2 = &b p3 = & a pointer to a 1-d array a pointer to a 1-d array a pointer to a 1-d array equivalene (*p1) p1 a (*p2) p2 b (*p3) p3 p1 p2 p3 1-d array pointers (int *) r taking no memory loations a b a a a a b b b b assume that array a, b, and are ontiguous in the memory of Array Pointers 9

10 Extending a 1-d pointer array a variable view int (*q)[4][4]; (int (*)[4]) q (int *) [4]) q an array of 1-d arrays q+1 (int *) [4]) q q+2 (int *) [4]) q assignment q = a q = b q = equivalene q *(q+0) a q *(q+1) b q *(q+2) taking onseutive memory loations 1-d array names assume arrays a, b, are onseutive q q q q q q q q q q q q of Array Pointers 10

11 1-d array pointer to onseutive 1-d arrays int (*p)[4]; a pointer to a pointer array p 1-d array pointer assignment p = &a equivalene *(p+0) p a *(p+1) p b *(p+2) p *(p+2) p d if arrays a, b,, d are onseutive p+0 p+1 p+2 p+3 p p p p p p p p p p p p p p p p p p p p of Array Pointers 11

12 A 2-d array and its sub-arrays array name int [4][4]; : the 2-d array name the 2-d array starting address the 1-d array pointer points to its 1 st 1-d sub-array ompilers do not alloate s memory loation a 2-d array with 4 rows and 4 olumns of Array Pointers 12

13 A 2-d array and its sub-arrays subarray names int [4][4]; [i] the 1-d array name the 1-d array starting address the 0-d array pointer points to its salar integer the 1 st 1-d subarray name the 2 nd 1-d subarray name the 3 rd 1-d subarray name the 4 th 1-d subarray name ompilers do not alloate [i] s memory loation a 2-d array with 4 rows and 4 olumns of Array Pointers 13

14 A 2-d array and its sub-arrays type sizes sizeof() = 4*4*4 bytes sizeof([i]) = 4*4 bytes sizeof([i][j]) = 4 bytes [i] [i][j] : the 2-d array name : the 1-d array name : the 0-d array name (a salar integer) a 2-d array with 4 rows and 4 olumns of Array Pointers 14

15 A 2-d array and its 1-d sub-arrays a type view 2-d array name int (*) [4] 1-d array pointer int (*) [4] 1-d subarray name int [4] 1-d subarray name int [4] 1-d subarray name int [4] 1-d subarray name int [4] and different types the same address of the starting element a 2-d array with 4 rows and 4 olumns (int (*) [4]) (int [4]) (int [4]) (int [4]) (int [4]) of Array Pointers 15

16 1-d subarray aggregated data type The 1 st subarray (=subarray name) sizeof() = 4*4 bytes (+0) : start address The 2 nd subarray (=subarray name) sizeof() = 4*4 bytes (+1) : start address The 3 rd subarray (=subarray name) sizeof() = 4*4 bytes (+2) : start address The 4 th subarray (=subarray name) sizeof() = 4*4 bytes (+3) : start address (int []) (int []) (int []) (int []) of Array Pointers 16

17 2-d array name as a pointer to a 1-d subarray 2-d array name 1-d array pointer 1-d array pointer +1 1-d array pointer +2 1-d array pointer +3 (int (*) [4]) (int (*) [4]) (int (*) [4]) (int (*) [4]) (int []) (int []) (int []) The 1 st subarray The 2 nd subarray The 3 rd subarray +3 (int []) The 4 th subarray of Array Pointers 17

18 1-d array and 0-d and 1-d array pointers 0-d array pointer : int pointer 1-d array pointer 0-d 1-d int (*m) ; int (*n) [4] ; int [4] ; int [4] ; (int (*)) m = ; (int(*)[4]) n = &; m = &; m[i] [i] (*n)[i] n[i] [i] of Array Pointers 18

19 2-d array and 1-d and 2-d array pointers 1-d array pointer 2-d array pointer 1-d 2-d int (*p) [4] ; int (*q) [4][4] ; int [4] [4] ; int [4][4] ; (int (*) [4]) p = ; p = &; (int(*)[4][4]) q = &; p[i] [i] (*q)[i][j] q[i][j] [i][j] of Array Pointers 19

20 1-d array pointer to the 1-d subarray of a 2-d array 1-d array pointer &p (int (*) [4]) p int (*p)[4] = ; p = ; An array pointer: sizeof(p) = 8 bytes 1-d sub-arrays : sizeof(*p) = 4*4 bytes q+1 (int (*) [4]) (int []) (int []) (int []) (int []) of Array Pointers 20

21 2-d array pointer to a 2-d array 2-d array pointer &q (int(*)[4][4]) q int (*q)[4][4] = &; q = &; An array pointer: sizeof(q) = 8 bytes 1-d sub-arrays : sizeof(*q) = 4*4*4 bytes q+1 (int (*) [4]) (int []) (int []) (int []) (int []) of Array Pointers 21

22 Using a 1-d array pointer to a 2-d array int (*p) [4] ; int [4] [4] 1-d array pointer &p (int (*) [4]) p p = ; p[i] [i] 1-d a 2-d array with 4 rows and 4 olumns (int (*) [4]) p p p p p p p p p p p p p p p p p p p p p p p p p of Array Pointers 22

23 Using a 2-d array pointer to a 2-d array int (*q) [4][4] ; int [4][4] ; 2-d array pointer &p (int(*)[4][4]) q q = &; (*q)[i] [i] 2-d a 2-d array with 4 rows and 4 olumns *q (int (*) [4]) C *q (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) (*q) of Array Pointers 23

24 (n-1)-d array pointer to a n-d array int a[4] ; 1-d array int (*p) ; 0-d array pointer (p = a) int b[4] ; 2-d array int (*q) ; 1-d array pointer (q = b) int [4] ; 3-d array int (*r) ; 2-d array pointer (r = ) int d[4] [4]; 4-d array int (*s) [4]; 3-d array pointer (s = d) of Array Pointers 24

25 n-d array name and (n-1)-d array pointer int a[4] ; p = &a; int (*p) ; p = a; p a a a int b[4] ; q = &b; int (*q) ; q = b; q b b b int [4] ; r = &; int (*r) ; r = ; r int d[4] [4]; s = &d; int (*s) [4]; s = d; s d d d of Array Pointers 25

26 n-d array pointer to a n-d array int a [4] ; 1-d array int (*p) [4]; 1-d array pointer (p = &a) int b [4]; 2-d array int (*q) [4]; 2-d array pointer (q = &b) int [4]; 3-d array int (*r) [4]; 3-d array pointer (r = &) int d [4][4]; 4-d array int (*s) [4][4]; 4-d array pointer (s = &d) of Array Pointers 26

27 n-d array name and n-d array pointer int a [4] ; p = &a; int (*p) [4]; &a p a a int b [4]; q = &b; int (*q) [4]; &b q b b int [4]; r = &; int (*r) [4]; & r int d [4][4]; s = &d; int (*s) [4][4]; &d s d d of Array Pointers 27

28 multi-dimensional array pointers p a q b r a a b a b b int a[4] ; 1-d array int (*p) ; 0-d array pointer int b[4] ; 2-d array int (*q) ; 1-d array pointer int [4] ; 3-d array int (*r) ; 2-d array pointer a b int d[4] [4]; 4-d array int (*s) [4]; 3-d array pointer of Array Pointers 28

29 Initializing multi-dimensional array pointers (1) p1 q2 r3 &a &b & a int a[4] ; int (*p1)[4] = &a ; b b int b[4]; int (*q2)[4] = &b; a int [4]; int (*r3)[4] = &; s4 &d d int d[4][4]; int (*s4)[4][4] = &d; d of Array Pointers 29

30 Initializing multi-dimensional array pointers (2) p0 q1 r2 a int a[4] ; int (*p0) = a ; b b int b[4]; int (*q1) = b; a int [4]; int (*r2) = ; s3 int d[4][4]; int (*s3)[4] = d; d d of Array Pointers 30

31 multi-dimensional array pointers int d[4] [4]; int (*s) [4]; d 4-d array name d[4][4] 3-d array pointer (*p)[4] d[i] 3-d array name d[i][4] 2-d array pointer (*q)[4] d[i][j] 2-d array name d[i][j][4] 1-d array pointer (*r)[4] d[i][j][k] 1-d array name d[i][j][k][4] 0-d array pointer (*s) i =[0..3], j = [0..1], k= [0..2] s d of Array Pointers 31

32 multi-dimensional array pointers int d[4] [4]; int (*s) [4]; d 4-d array name d[4][4] p[i][j][k][l] 3-d array pointer (*p)[4] int (*p)[4] = d; d[i] 3-d array name d[i][4] q[j][k][l] 2-d array pointer (*q)[4] int (*q)[4] = d[i]; d[i][j] 2-d array name d[i][j][4] r[k][l] 1-d array pointer (*r)[4] int (*r)[4] = d[i][j]; d[i][j][k] 1-d array name d[i][j][k][4] s[l] 0-d array pointer (*s) int (*s) = d[i][j][k]; i =[0..3], j = [0..1], k= [0..2] of Array Pointers 32

33 Passing multidimensional array names int a[4] ; int (*p) ; all funa(a, ); prototype void funa(int (*p), ); int b[4] ; int (*q) ; all funb(b, ); prototype void funb(int (*q), ); int [4] ; int (*r) ; all fun(, ); prototype void fun(int (*r), ); int d[4] [4]; int (*s) [4]; all fund(d, ); prototype void fund(int (*s)[4], ); of Array Pointers 33

34 Referenes Essential C, Nik Parlante Effiient C Programming, Mark A. Weiss C A Referene Manual, Samuel P. Harbison & Guy L. Steele Jr. [4] C Language Express, I. K. Chun

Pointers (1A) Young Won Lim 11/1/17

Pointers (1A) Young Won Lim 11/1/17 Pointers (1A) Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Applications of Pointers (1A) Young Won Lim 12/26/17

Applications of Pointers (1A) Young Won Lim 12/26/17 Applications of (1A) Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information

Applications of Pointers (1A) Young Won Lim 4/24/18

Applications of Pointers (1A) Young Won Lim 4/24/18 (1A) Coyright (c) 2010-2018 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version ublished

More information

Pointers (1A) Young Won Lim 1/9/18

Pointers (1A) Young Won Lim 1/9/18 Pointers (1A) Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Pointers (1A) Young Won Lim 1/5/18

Pointers (1A) Young Won Lim 1/5/18 Pointers (1A) Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Applications of Pointers (1A) Young Won Lim 4/11/18

Applications of Pointers (1A) Young Won Lim 4/11/18 (1A) Coyright (c) 2010-2018 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version ublished

More information

Applications of Pointers (1A) Young Won Lim 1/5/18

Applications of Pointers (1A) Young Won Lim 1/5/18 Alications of (1A) Coyright (c) 2010-2017 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Applications of Arrays (1A) Young Won Lim 2/11/17

Applications of Arrays (1A) Young Won Lim 2/11/17 Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Applications of Pointers (1A) Young Won Lim 2/27/18

Applications of Pointers (1A) Young Won Lim 2/27/18 Alications of (1A) Coyright (c) 2010-2018 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Applications of Pointers (1A) Young Won Lim 3/14/18

Applications of Pointers (1A) Young Won Lim 3/14/18 (1A) Coyright (c) 2010-2018 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version ublished

More information

Pointers (1A) Young Won Lim 10/18/17

Pointers (1A) Young Won Lim 10/18/17 Pointers (1A) Coyright (c) 2010-2013 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Applications of Pointers (1A) Young Won Lim 3/21/18

Applications of Pointers (1A) Young Won Lim 3/21/18 (1A) Coyright (c) 2010-2018 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version ublished

More information

Applications of Pointers (1A) Young Won Lim 3/31/18

Applications of Pointers (1A) Young Won Lim 3/31/18 (1A) Coyright (c) 2010-2018 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version ublished

More information

Applications of Arrays (1A) Young Won Lim 3/15/17

Applications of Arrays (1A) Young Won Lim 3/15/17 Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Pointers (1A) Young Won Lim 10/23/17

Pointers (1A) Young Won Lim 10/23/17 Pointers (1A) Coyright (c) 2010-2013 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Pointers (1A) Young Won Lim 3/5/18

Pointers (1A) Young Won Lim 3/5/18 Pointers (1A) Copyright (c) 2010-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Arrays (1A) Young Won Lim 12/4/17

Arrays (1A) Young Won Lim 12/4/17 Arrays (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Pointers (1A) Young Won Lim 1/14/18

Pointers (1A) Young Won Lim 1/14/18 Pointers (1A) Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Arrays (1A) Young Won Lim 1/27/17

Arrays (1A) Young Won Lim 1/27/17 Arrays (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Pointers (1A) Young Won Lim 1/22/18

Pointers (1A) Young Won Lim 1/22/18 Pointers (1A) Copyright (c) 2010-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Overview (1A) Young Won Lim 9/14/17

Overview (1A) Young Won Lim 9/14/17 Overview (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Overview (1A) Young Won Lim 9/9/17

Overview (1A) Young Won Lim 9/9/17 Overview (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Overview (1A) Young Won Lim 9/25/17

Overview (1A) Young Won Lim 9/25/17 Overview (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Applications of Structures (1A) Young Won Lim 12/8/17

Applications of Structures (1A) Young Won Lim 12/8/17 Applications of (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information

Function Overview (1A) Young Won Lim 10/23/17

Function Overview (1A) Young Won Lim 10/23/17 Function Overview (1A) Copyright (c) 2010 2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Pointers (1A) Young Won Lim 2/6/18

Pointers (1A) Young Won Lim 2/6/18 Pointers (1A) Copyright (c) 2010-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Applications of Structures (1A) Young Won Lim 12/4/17

Applications of Structures (1A) Young Won Lim 12/4/17 Applications of (1A) Copyright (c) 2009-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information

Memory Arrays (4H) Gate Level Design. Young Won Lim 3/15/16

Memory Arrays (4H) Gate Level Design. Young Won Lim 3/15/16 Arrays (4H) Gate Level Design Young Won Lim 3/15/16 Copyright (c) 2011, 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation

More information

Example 2. Young Won Lim 11/24/17

Example 2. Young Won Lim 11/24/17 Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Pointers (1A) Young Won Lim 12/4/17

Pointers (1A) Young Won Lim 12/4/17 Pointers (1A) Coyright (c) 2010-2017 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Pointers (1A) Young Won Lim 2/10/18

Pointers (1A) Young Won Lim 2/10/18 Pointers (1A) Copyright (c) 2010-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Structure (1A) Young Won Lim 7/30/13

Structure (1A) Young Won Lim 7/30/13 Structure (1A) Copyright (c) 2010 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Type (1A) Young Won Lim 2/17/18

Type (1A) Young Won Lim 2/17/18 Type (1A) Copyright (c) 2010-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Example 1. Young Won Lim 11/17/17

Example 1. Young Won Lim 11/17/17 Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Example 1 : using 1-d arrays. Young Won Lim 12/13/17

Example 1 : using 1-d arrays. Young Won Lim 12/13/17 : using 1-d arrays Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information

File (1A) Young Won Lim 11/25/16

File (1A) Young Won Lim 11/25/16 File (1A) Copyright (c) 2010-2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Structures (1A) Young Won Lim 12/4/17

Structures (1A) Young Won Lim 12/4/17 Structures (1A) Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Memory (1A) Young Won Lim 9/7/17

Memory (1A) Young Won Lim 9/7/17 (1A) Copyright (c) 21-26 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Structures (1A) Young Won Lim 11/8/16

Structures (1A) Young Won Lim 11/8/16 Structures (1A) Copyright (c) 2010-2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Number System (1A) Young Won Lim 7/7/10

Number System (1A) Young Won Lim 7/7/10 Number System (A) 7/7/ Copyrigt (c) 9-6 Young W. Lim. Permission is granted to copy, distribute and/or modify tis document under te terms of te GNU ree Documentation License, Version. or any later version

More information

Example 3 : using a structure array. Young Won Lim 11/25/17

Example 3 : using a structure array. Young Won Lim 11/25/17 : using a structure array Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Example 3. Young Won Lim 11/22/17

Example 3. Young Won Lim 11/22/17 Copyright (c) 2010-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Variables (2D) Young Won Lim 3/28/18

Variables (2D) Young Won Lim 3/28/18 Variables (2D) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Arrays and Strings (2H) Young Won Lim 3/7/18

Arrays and Strings (2H) Young Won Lim 3/7/18 Arrays and Strings (2H) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

ELF (1A) Young Won Lim 10/22/14

ELF (1A) Young Won Lim 10/22/14 ELF (1A) Copyright (c) 2010-2014 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Expressions (2E) Young Won Lim 3/10/18

Expressions (2E) Young Won Lim 3/10/18 Expressions (2E) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Expressions (2E) Young Won Lim 4/9/18

Expressions (2E) Young Won Lim 4/9/18 Expressions (2E) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Pointers (2G) Young Won Lim 3/7/18

Pointers (2G) Young Won Lim 3/7/18 Pointers (2G) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Program Structure (2A) Young Won Lim 3/8/18

Program Structure (2A) Young Won Lim 3/8/18 Program Structure (2A) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

ARM Assembly Exercise (1B) Young Won Lim 7/16/16

ARM Assembly Exercise (1B) Young Won Lim 7/16/16 ARM Assembly Exercise (1B) Copyright (c) 2014-2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Program Structure (2A) Young Won Lim 5/28/18

Program Structure (2A) Young Won Lim 5/28/18 Program Structure (2A) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Accessibility (1A) Young Won Lim 8/22/13

Accessibility (1A) Young Won Lim 8/22/13 Accessibility (1A) Copyright (c) 2011-2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information

Class (1A) Young Won Lim 9/8/14

Class (1A) Young Won Lim 9/8/14 Class (1A) Copyright (c) 2011-2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Algorithms Bubble Sort (1B) Young Won Lim 4/5/18

Algorithms Bubble Sort (1B) Young Won Lim 4/5/18 Algorithms Bubble Sort (1B) Young Won Lim 4/5/18 Copyright (c) 2017 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation

More information

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19 Access Young W. Lim 2017-06-10 Sat Young W. Lim Access 2017-06-10 Sat 1 / 19 Outline 1 Introduction References IA32 Operand Forms Data Movement Instructions Data Movement Examples Young W. Lim Access 2017-06-10

More information

Structures (2I) Young Won Lim 4/17/18

Structures (2I) Young Won Lim 4/17/18 Structures (2I) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

ELF (1A) Young Won Lim 3/24/16

ELF (1A) Young Won Lim 3/24/16 ELF (1A) Copyright (c) 21-216 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Day02 A. Young W. Lim Sat. Young W. Lim Day02 A Sat 1 / 12

Day02 A. Young W. Lim Sat. Young W. Lim Day02 A Sat 1 / 12 Day02 A Young W. Lim 2017-10-07 Sat Young W. Lim Day02 A 2017-10-07 Sat 1 / 12 Outline 1 Based on 2 Introduction (2) - Basic Elements Basic Elements in C Programming Young W. Lim Day02 A 2017-10-07 Sat

More information

The Complexity of Algorithms (3A) Young Won Lim 4/3/18

The Complexity of Algorithms (3A) Young Won Lim 4/3/18 Copyright (c) 2015-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler)

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler) 1 Arrays General Questions 1. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array? A. The element will be set to 0. B. The compiler would

More information

At this time we have all the pieces necessary to allocate memory for an array dynamically. Following our example, we allocate N integers as follows:

At this time we have all the pieces necessary to allocate memory for an array dynamically. Following our example, we allocate N integers as follows: Pointers and Arrays Part II We will continue with our discussion on the relationship between pointers and arrays, and in particular, discuss how arrays with dynamical length can be created at run-time

More information

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18 Access Young W. Lim 2017-01-27 Fri Young W. Lim Access 2017-01-27 Fri 1 / 18 Outline 1 Introduction References IA32 Operand Forms Data Movement Instructions Young W. Lim Access 2017-01-27 Fri 2 / 18 Based

More information

Functions (4A) Young Won Lim 5/8/17

Functions (4A) Young Won Lim 5/8/17 Functions (4A) Copyright (c) 2015 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Structures (2I) Young Won Lim 3/7/18

Structures (2I) Young Won Lim 3/7/18 Structures (2I) Copyright (c) 2014-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Class (1A) Young Won Lim 11/20/14

Class (1A) Young Won Lim 11/20/14 Class (1A) Copyright (c) 2011 2014 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Day05 A. Young W. Lim Sat. Young W. Lim Day05 A Sat 1 / 14

Day05 A. Young W. Lim Sat. Young W. Lim Day05 A Sat 1 / 14 Day05 A Young W. Lim 2017-10-07 Sat Young W. Lim Day05 A 2017-10-07 Sat 1 / 14 Outline 1 Based on 2 Structured Programming (2) Conditions and Loops Conditional Statements Loop Statements Type Cast Young

More information

RAM (1A) Young Won Lim 11/12/13

RAM (1A) Young Won Lim 11/12/13 RAM (1A) Young Won Lim 11/12/13 opyright (c) 2011-2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version

More information

Functions (4A) Young Won Lim 3/16/18

Functions (4A) Young Won Lim 3/16/18 Functions (4A) Copyright (c) 2015 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Side Effects (3A) Young Won Lim 1/13/18

Side Effects (3A) Young Won Lim 1/13/18 Side Effects (3A) Copyright (c) 2016-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Lecture (07) Arrays. By: Dr. Ahmed ElShafee. Dr. Ahmed ElShafee, ACU : Fall 2015, Programming I

Lecture (07) Arrays. By: Dr. Ahmed ElShafee. Dr. Ahmed ElShafee, ACU : Fall 2015, Programming I Lecture (07) Arrays By: Dr Ahmed ElShafee ١ introduction An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type Instead

More information

LOÏC CAPPANERA. 1. Memory management The variables involved in a C program can be stored either statically or dynamically.

LOÏC CAPPANERA. 1. Memory management The variables involved in a C program can be stored either statically or dynamically. C PROGRAMMING LANGUAGE. MEMORY MANAGEMENT. APPLICATION TO ARRAYS. CAAM 519, CHAPTER 7 This chapter aims to describe how a programmer manages the allocation of memory associated to the various variables

More information

Two Dimensional Arrays

Two Dimensional Arrays 2-d Arrays 1 Two Dimensional Arrays We have seen that an array variable can store a list of values Many applications require us to store a table of values Student 1 Student 2 Student 3 Student 4 Subject

More information

Binary Search Tree (3A) Young Won Lim 6/2/18

Binary Search Tree (3A) Young Won Lim 6/2/18 Binary Search Tree (A) /2/1 Copyright (c) 2015-201 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Day08 A. Young W. Lim Mon. Young W. Lim Day08 A Mon 1 / 27

Day08 A. Young W. Lim Mon. Young W. Lim Day08 A Mon 1 / 27 Day08 A Young W. Lim 2017-10-16 Mon Young W. Lim Day08 A 2017-10-16 Mon 1 / 27 Outline 1 Based on 2 C Functions (2) Storage Class and Scope Storage Class Specifiers A. Storage Duration B. Scope C. Linkage

More information

Side Effects (3B) Young Won Lim 11/20/17

Side Effects (3B) Young Won Lim 11/20/17 Side Effects (3B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Side Effects (3B) Young Won Lim 11/23/17

Side Effects (3B) Young Won Lim 11/23/17 Side Effects (3B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Polymorphism (1A) Young Won Lim 8/22/13

Polymorphism (1A) Young Won Lim 8/22/13 Polymorhism (1A) Coyright (c) 2011-2012 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Day06 A. Young W. Lim Mon. Young W. Lim Day06 A Mon 1 / 16

Day06 A. Young W. Lim Mon. Young W. Lim Day06 A Mon 1 / 16 Day06 A Young W. Lim 2017-09-18 Mon Young W. Lim Day06 A 2017-09-18 Mon 1 / 16 Outline 1 Based on 2 Introduction C Program Control Young W. Lim Day06 A 2017-09-18 Mon 2 / 16 Based on "C How to Program",

More information

Binary Search Tree (2A) Young Won Lim 5/17/18

Binary Search Tree (2A) Young Won Lim 5/17/18 Binary Search Tree (2A) Copyright (c) 2015-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Algorithms (7A) Young Won Lim 4/10/17

Algorithms (7A) Young Won Lim 4/10/17 Algorithms (7A) Copyright (c) 2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Side Effects (3B) Young Won Lim 11/27/17

Side Effects (3B) Young Won Lim 11/27/17 Side Effects (3B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Day06 A. Young W. Lim Wed. Young W. Lim Day06 A Wed 1 / 26

Day06 A. Young W. Lim Wed. Young W. Lim Day06 A Wed 1 / 26 Day06 A Young W. Lim 2017-09-20 Wed Young W. Lim Day06 A 2017-09-20 Wed 1 / 26 Outline 1 Based on 2 C Program Control Overview for, while, do... while break and continue Relational and Logical Operators

More information

Pointers, Arrays and Parameters

Pointers, Arrays and Parameters Pointers, Arrays and Parameters This exercise is different from our usual exercises. You don t have so much a problem to solve by creating a program but rather some things to understand about the programming

More information

Polymorphism (1A) Young Won Lim 8/15/13

Polymorphism (1A) Young Won Lim 8/15/13 Polymorhism (1A) Coyright (c) 2011-2012 Young W. Lim. Permission is granted to coy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Algorithms (7A) Young Won Lim 4/18/17

Algorithms (7A) Young Won Lim 4/18/17 Algorithms (7A) Copyright (c) 2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Algorithms Overview (1A) Young Won Lim 3/29/18

Algorithms Overview (1A) Young Won Lim 3/29/18 Algorithms Overview (1A) Copyright (c) 2017 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

More Arrays. Last updated 2/6/19

More Arrays. Last updated 2/6/19 More Last updated 2/6/19 2 Dimensional Consider a table 1 2 3 4 5 6 5 4 3 2 12 11 13 14 15 19 17 16 3 1 4 rows x 5 columns 2 tj 2 Dimensional Consider a table 1 2 3 4 5 6 5 4 3 2 12 11 13 14 15 19 17 16

More information

Tiny CPU Data Path (2B) Young Won Lim 5/2/16

Tiny CPU Data Path (2B) Young Won Lim 5/2/16 Tiny CPU Data Path (2B) Copyright (c) 24-26 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version.2 or any later

More information

Eulerian Cycle (2A) Young Won Lim 4/26/18

Eulerian Cycle (2A) Young Won Lim 4/26/18 Eulerian Cycle (2A) Copyright (c) 2015 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information

CORDIC Fixed Point Simulation. Young Won Lim 2/28/12

CORDIC Fixed Point Simulation. Young Won Lim 2/28/12 CORDIC Fixed Point Simulation Copyright (c) 2012 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Background Functions (1C) Young Won Lim 4/3/18

Background Functions (1C) Young Won Lim 4/3/18 Background Functions (1C) Copright (c) 2016-2017 Young W. Lim. Permission is granted to cop, distribute and/or modif this document under the terms of the GNU Free Documentation License, Version 1.2 or

More information

Outline. Computer Memory Structure Addressing Concept Introduction to Pointer Pointer Manipulation Summary

Outline. Computer Memory Structure Addressing Concept Introduction to Pointer Pointer Manipulation Summary Pointers 1 2 Outline Computer Memory Structure Addressing Concept Introduction to Pointer Pointer Manipulation Summary 3 Computer Memory Revisited Computers store data in memory slots Each slot has an

More information

Binary Search Tree (3A) Young Won Lim 6/4/18

Binary Search Tree (3A) Young Won Lim 6/4/18 Binary Search Tree (A) /4/1 Copyright (c) 2015-201 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

State Monad Example (3H) Young Won Lim 2/16/18

State Monad Example (3H) Young Won Lim 2/16/18 Copyright (c) 2016-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

A Sudoku Solver (1A) Richard Bird Implementation. Young Won Lim 11/15/16

A Sudoku Solver (1A) Richard Bird Implementation. Young Won Lim 11/15/16 A Sudoku Solver (1A) Richard Bird Implementation Copyright (c) 2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License,

More information

Warmup January 9th, What is the value of the following C expression? 8*9 % 10/ 2

Warmup January 9th, What is the value of the following C expression? 8*9 % 10/ 2 Warmup January 9th, 2018 What is the value of the following C expression? 8*9 % 10/ 2 Warmup January 11th, 2018 What is the value of the following C expression? ( -42 3!= 3) && ( -3 < -2 < -1) Warmup January

More information

Binary Search Tree (3A) Young Won Lim 6/6/18

Binary Search Tree (3A) Young Won Lim 6/6/18 Binary Search Tree (A) //1 Copyright (c) 2015-201 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Background Functions (1C) Young Won Lim 12/6/17

Background Functions (1C) Young Won Lim 12/6/17 Background Functions (1C) Copright (c) 2016-2017 Young W. Lim. Permission is granted to cop, distribute and/or modi this document under the terms o the GNU Free Documentation License, Version 1.2 or an

More information

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27 Procedure Calls Young W. Lim 2016-11-05 Sat Young W. Lim Procedure Calls 2016-11-05 Sat 1 / 27 Outline 1 Introduction References Stack Background Transferring Control Register Usage Conventions Procedure

More information

HW / SW Implementation Overview (0A) Young Won Lim 7/16/16

HW / SW Implementation Overview (0A) Young Won Lim 7/16/16 HW / SW Implementation Copyright (c) 213-216 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any

More information