Applications of Pointers (1A) Young Won Lim 4/24/18
|
|
- Mervyn Campbell
- 5 years ago
- Views:
Transcription
1 (1A)
2 Coyright (c) 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 by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A coy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was roduced by using LibreOffice.
3 Variables and their addresses address data int a; &a a int * ; & int **q; &q q 3
4 Initialization of Variables address data int a = 100; &a a = 100 int * = &a; & = &a int **q = &; &q q = & 4
5 Traditional arrow notations address data address data &a a = 100 &a a = 100 & = &a & = &a &q q = & &q q = & 5
6 Pointed addresses :, q address data int a; a int * = &a; q int **q = &; &q q = &a q = & 6
7 Dereferenced Variables : * address data int a; * * a int * = &a; & int **q = &; 7
8 Dereferenced Variables : * int a; int * = &a; int **q = &; Address assignment = &a &a *() *(&a) * a Variable aliasing * a Relations after address assignment 8
9 Dereferenced Variables : *q, **q address data int a; *q **q **q a int * = &a; q *q *q int **q = &; &q q 9
10 Dereferenced Variables : *q, **q int a; int * = &a; Address assignment = &a Variable aliasing * a int **q = &; q = & *q **q a q & *(q) *(&) * q **q * **q a Relations after address assignment 10
11 Two more ways to access a : *, **q &a a * *q **q & & q *q &q q &q q &q q a * a **q a 11
12 Two more ways to access a : *, **q address data &a & a * **q &q q 1) Read / Write a 2) Read / Write * 3) Read / Write **q 12
13 Variables int a; a can hold an integer address &a data a a = 100; a holds 100 address &a data a
14 Pointer Variables int * ; can hold an address int * ; holds an address of a int tye data & ointer to int int * ; * holds a int tye data int * 14
15 Pointer to Pointer Variable int ** q; q holds an address int ** q; q holds an address of a ointer to int tye data ointer to ointer to int &q q int * *q; ointer to int *q holds an address of a int tye data q *q int **q; **q holds a int tye data *q **q int 15
16 Pointer Variables Examles int a = 200; &a address 0x3A0 a data 200 int * = & a; & 0x3AB 0x3A0 int ** q = & ; &q 0x3CE q = 0x3AB &q 0x3CE q 0x3AB *q 0x3A0 **q
17 Pointer Variable with an arrow notation address data * &a address 0x3A0 a data 200 & & 0x3AB 0x3A0 using an arrow notation & * 0x3AB 0x3A
18 Pointer Variable q with an arrow notation address data address data *q **q &a 0x3A0 a 200 q *q & 0x3AB 0x3A0 &q q &q 0x3CE q = 0x3AB using an arrow notation &q q 0x3CE 0x3AB *q 0x3A0 **q
19 The tye view oint of ointers data address (int *) address (int **) Tyes 19
20 The different view oints of ointers **q *q (int *) *q q (int **) q &q Tyes Variables Addresses 20
21 Single and Double Pointer Examles (1) int a ; int * ; int **q ; a * a, *, and **q: int variables q q *q *q **q 21
22 Single and Double Pointer Examles (2) int a ; int * ; int * *q ; a * and *q : int ointer variables (singleointers) q q *q *q **q 22
23 Single and Double Pointer Examles (3) int a ; int * ; int ** q ; a * q : double int ointer variables q q *q *q **q 23
24 Values of double ointer variables int **, **q ; (int **) (int **) X X = q; (int *) (float *) (float) 24
25 Pointed Addresses and Data int a ; &a a =100 The variable a holds an integer data int * ; & 200 The ointer variable holds an address, at this address, an integer data is stored int * * q ; &q q *q 30 The ointer variable q holds an address, at the address q, another address *q is stored, at the address *q, an integer data **q is stored 25
26 Dereferencing Oerations * int a &a a =100 *(&a) = a * * int * & *=200 *(&) = *() = * * * * int * * q &q q q *q *q **q=30 *(&q) = q *(q) = *q *(*q) = **q 26
27 Direct Access to an integer a int a ; &a a =100 Direct Access address &a value a integer 1 memory access 27
28 Indirect Access * to an integer a int * ; & *=200 Indirect Access address & value 2 memory accesses Dereference Oerator * the content of the ointed location * 28
29 Double Indirect Access **q to an integer a int * * q ; &q q q *q *q **q=30 Double Indirect Access address &q value q 3 memory accesses Dereference Oerator * the content of the ointed location q *q Dereference Oerator * the content of the ointed location *q **q 29
30 Values of Variables int a ; &a a =100 address &a value a integer int * ; & *=200 address value & * address integer int * * q ; &q q q *q *q **q=30 address value &q q q *q *q **q address address integer 30
31 Swaing ointers - ass by reference - double ointers 31
32 Swaing integer ointers & = &a & = &b &q q = &b &q q = &a a = 111 a = 111 b = 222 b =
33 Swaing integer ointers & = &a & = &b &q q = &b &q q = &a int *, *q; swa_ointers( &, &q ); swa_ointers( int **, int ** ); function call function rototye 33
34 Pass by integer ointer reference void swa_ointers (int **m, int **n) { int* tm; int ** m int * *m int ** n int * *n } tm = *m; *m = *n; *n = tm; int * tm int a, b; int *, *q; =&a, q=&b; swa_ointers( &, &q ); 34
35 Array of Pointers 35
36 Array of Pointers int a [4]; int * b [4]; int a [4] No. of elements = 4 Tye of each element int * No. of elements = 4 b [4] Tye of each element 36
37 Array of Pointers variable view int a [4]; int * b [4]; a b b[0] *b[0] = 11 a[0] = 11 b[0] a[1] = 22 b[1] b[1] *b[1] = 22 a[2] = 33 b[2] a[3] = 44 b[3] b[2] *b[2] = 33 b[3] *b[3] = 44 37
38 Array of Pointers tye view int a [4]; int * b [4]; (int *) (int * *) (int *) (int *) (int *) (int *) 38
39 Pointer to Arrays 39
40 Pointer to an array variable declarations int m ; int *n ; an integer ointer int a [4] int func (int a, int b) ; int (*) [4] an integer array ointer int (* f) (int a, int b) ; a function ointer 40
41 Pointer to an array a tye view int int * an integer ointer int [] int (*) [4] an integer array ointer int (int, int) int (*) (int, int) a function ointer 41
42 Pointer to an Array : Assignment and Dereference int a [4] a &a &a int (*) [4] (*) &(*) dereference assignment sizeof()= 8 bytes sizeof(*)= 16 bytes 42
43 Pointer to an array a variable view int (*) [4]; an array ointer oints to an array a aggregated tye data = &a &a a a a+1 a+2 a+3 a[0] a[1] a[2] a[3] int a [4]; 43
44 Pointer to an array a aggregated tye view int (*) [4]; An aggregated tye - starting address (&a) - size of all the array elements (16 bytes) a a[0] a[1] a[2] a[3] 4 * sizeof 44
45 Pointer to an array incrementing a ointer int (*) [4]; addr(+1) - addr() = (long) (+1) - (long) () = 4 * sizeof a a[0] a[1] a[2] 4*sizeof a[3] +1 4*sizeof 45
46 Pointer to an array dereferencing int a [4]; int (*) [4] = &a; = &a assignment &a a * * a dereference a[0] a[1] a[2] a[3] (*)[0] (*)[1] (*)[2] (*)[3] 46
47 Pointer to an array a tye view int a [4]; int (*) [4] = &a; (int (*)[4]) (int (*)[4]) (int *) (int *) [4]) (int []) 47
48 Double ointer to an array a tye view (int (*)[4]) (**)[4]) a ointer to a ointer to an array (int (*)[4]) a ointer to an array (int *) [4]) (int []) (int *) a ointer to an int 48
49 Series of ointers to an array a tye view a ointer to an int (int *) a ointer to an array (int (*)[4]) (int *) [4]) (int (*)[4]) (int *) [4]) (int (*)[4]) (int *) [4]) an int array name an int array name an int array name 49
50 Pointer to the series of arrays tye int [4] int [ ] int * (int (*)[4]) (int *) [4]) 4 in [4] is meaningful only in the array declaration the number of array elements (int *) [4]) (int *) [4]) 50
51 Array ointers and 2-d arrays the array name c of a 2-d array as an array ointer which oints to its 1 st 1-d sub-array with 4 elements. c+1 oints to the 2 nd 1-d sub-array c+2 oints to the 3 rd 1-d sub-array An array of array ointers an aggregated data structure that has the starting address and its size. 2-d array : sizeof(c) = 64 bytes 1-d sub-arrays : sizeof(*c) = 16 bytes a 2-d array with 4 rows and 4 columns (int (*) [4]) c (int []) (int []) (int []) (int []) c[0] c[1] c[2] c[3] c[0][0] c[0][1] c[0][2] c[0][3] c[1][0] c[1][1] c[1][2] c[1][3] c[2][0] c[2][1] c[2][2] c[2][3] c[3][0] c[3][1] c[3][2] c[3][3] 51
52 Pointer to a 1-d array & (int (*) [4]) = &c[0]; An array ointer: sizeof() = 8 bytes 1-d sub-arrays : sizeof(*) = 16 bytes (int (*) [4]) c (int []) (int []) (int []) (int []) c[0] c[1] c[2] c[3] c[0][0] c[0][1] c[0][2] c[0][3] c[1][0] c[1][1] c[1][2] c[1][3] c[2][0] c[2][1] c[2][2] c[2][3] c[3][0] c[3][1] c[3][2] c[3][3] 52
53 Pointer to a 2-d array &q (int(*)[4][4]) q = &c; q An array ointer: sizeof(q) = 8 bytes 1-d sub-arrays : sizeof(*q) = 64 bytes q+1 (int (*) [4]) c (int []) (int []) (int []) (int []) c[0] c[1] c[2] c[3] c[0][0] c[0][1] c[0][2] c[0][3] c[1][0] c[1][1] c[1][2] c[1][3] c[2][0] c[2][1] c[2][2] c[2][3] c[3][0] c[3][1] c[3][2] c[3][3] 53
54 Usinga a ointer to a 1-d array & int (*) [4] ; int c[4] [4] (int (*) [4]) = &c[0]; a 2-d array with 4 rows and 4 columns (int (*) [4]) c [0] [1] [2] [3] [0] [1] [2] [3] [0][0] [0][1] [0][2] [0][3] [1][0] [1][1] [1][2] [1][3] [2][0] [2][1] [2][2] [2][3] [3][0] [3][1] [3][2] [3][3] 54
55 Using a ointer to a 2-d array & int (*q) [4][4] ; int c [4][4] ; (int(*)[4][4]) q q = &c; a 2-d array with 4 rows and 4 columns (int (*) [4]) c (*q)[0] (*q)[1] (*q)[2] (*q)[3] (*)[0] (*)[1] (*)[2] (*)[3] (*q)[0][0] (*q)[0][1] (*q)[0][2] (*q)[0][3] (*q)[1][0] (*q)[1][1] (*q)[1][2] (*q)[1][3] (*q)[2][0] (*q)[2][1] (*q)[2][2] (*q)[2][3] (*q)[3][0] (*q)[3][1] (*q)[3][2] (*q)[3][3] 55
56 Pointer to array (4) int c [4][4]; int (*) [4]; = c; func(,... ); void func(int (*x)[4],... ) { } x[r][c] = void func(int x[ ][4],... ) { } x[r][c] = 56
57 References [1] Essential C, Nick Parlante [2] Efficient C Programming, Mark A. Weiss [3] C A Reference Manual, Samuel P. Harbison & Guy L. Steele Jr. [4] C Language Exress, I. K. Chun
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 informationApplications 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 informationApplications 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 informationApplications 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 informationApplications 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 informationApplications 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 informationPointers (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 informationPointers (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 informationPointers (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 informationPointers (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 informationApplications 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 informationPointers (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 informationApplications 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 informationArrays (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 informationApplications 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 informationOverview (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 informationPointers (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 informationPointers (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 informationArrays (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 informationOverview (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 informationApplications 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 informationOverview (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 informationApplications 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 informationPointers (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 informationPointers (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 informationPointers (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 informationPointers (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 informationFunction 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 informationMemory 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 informationType (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 informationApplications of Array Pointers (1A) Young Won Lim 11/22/18
Appliations of Array Pointers (1A) Copyright () 2010-2018 Young W. Lim. Permission is granted to opy, distribute and/or modify this doument under the terms of the GNU Free Doumentation Liense, Version
More informationStructure (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 informationMemory (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 informationStructures (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 informationFile (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 informationStructures (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 informationNumber 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 informationPolymorphism (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 informationArrays 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 informationPolymorphism (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 informationExample 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 informationVariables (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 informationPointers (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 informationExample 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 informationExample 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 informationELF (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 informationExample 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 informationExpressions (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 informationProgram 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 informationExample 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 informationExpressions (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 informationProgram 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 informationARM 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 informationLecture06: Pointers 4/1/2013
Lecture06: Pointers 4/1/2013 Slides modified from Yin Lou, Cornell CS2022: Introduction to C 1 Pointers A ointer is a variable that contains the (memory) address of another variable What is a memory address?
More informationAccessibility (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 informationAlgorithms 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 informationDefinition. Pointers. Outline. Why pointers? Definition. Memory Organization Overview. by Ziad Kobti. Definition. Pointers enable programmers to:
Pointers by Ziad Kobti Deinition When you declare a variable o any tye, say: int = ; The system will automatically allocated the required memory sace in a seciic location (tained by the system) to store
More informationClass (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 informationStructures (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 informationBinary 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 informationStructures (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 informationPointers and Memory Allocation p. 1. Brooklyn College. Michael Lampis. CISC 3130 Notes. Pointers and Memory Allocation
Pointers and Memory Allocation CISC 3130 Notes Michael Lamis mlamis@cs.ntua.gr Brooklyn College Pointers and Memory Allocation. 1 int x; Pointers x Pointers and Memory Allocation. 2 Pointers int x; int
More informationClass (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 informationThe 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 informationBinary 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 informationRAM (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 informationFunctions (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 informationAccess. 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 informationSide 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 informationELF (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 informationCMPE-013/L. Introduction to C Programming
CMPE-013/L Introduction to C Programming Gabriel Hugh Elkaim Winter 2015 and memory Pointer/array equivalency Pointer arithmetic and the stack and strings Arrays of ointers 1 Syntax tye *trname; How to
More informationEulerian 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 informationStorage Allocation CSE 143. Pointers, Arrays, and Dynamic Storage Allocation. Pointer Variables. Pointers: Review. Pointers and Types
CSE 143 Pointers, Arrays, and Dynamic Storage Allocation [Chater 4,. 148-157, 172-177] Storage Allocation Storage (memory) is a linear array of cells (bytes) Objects of different tyes often reuire differing
More informationBinary 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 informationFunctions (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 informationAlgorithms 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 informationBinary 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 informationSide 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 informationDay08 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 informationPointers. 1 Background. 1.1 Variables and Memory. 1.2 Motivating Pointers Massachusetts Institute of Technology
Introduction to C++ Massachusetts Institute of Technology ocw.mit.edu 6.096 Pointers 1 Background 1.1 Variables and Memory When you declare a variable, the computer associates the variable name with a
More informationDeclaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:
1 Programming in C Pointer Variable A variable that stores a memory address Allows C programs to simulate call-by-reference Allows a programmer to create and manipulate dynamic data structures Must be
More informationState 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 informationPointers. 10/5/07 Pointers 1
Pointers 10/5/07 Pointers 1 10/5/07 Pointers 2 Variables Essentially, the computer's memory is made up of bytes. Each byte has an address, associated with it. 10/5/07 Pointers 3 Variable For example 1:#include
More informationPersonal SE. Computer Memory Addresses C Pointers
Personal SE Computer Memory Addresses C Pointers Computer Memory Organization Memory is a bucket of bytes. Computer Memory Organization Memory is a bucket of bytes. Each byte is 8 bits wide. Computer Memory
More informationAccess. 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 informationAt 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 informationMonad Background (3A) Young Won Lim 11/20/17
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 version published
More informationArrays. Young W. Lim Mon. Young W. Lim Arrays Mon 1 / 17
Arrays Young W. Lim 2017-02-06 Mon Young W. Lim Arrays 2017-02-06 Mon 1 / 17 Outline 1 Introduction References Array Background Young W. Lim Arrays 2017-02-06 Mon 2 / 17 Based on "Self-service Linux: Mastering
More informationCS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018
CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make
More informationa data type is Types
Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental
More informationWhat is an algorithm?
Announcements CS 142 C++ Pointers Reminder Program 6 due Sunday, Nov. 9 th by 11:55pm 11/3/2014 2 Pointers and the Address Operator Pointer Variables Each variable in a program is stored at a unique address
More informationSide 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 informationDay06 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 informationSide 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 informationCSC 211 Intermediate Programming. Pointers
CSC 211 Intermediate Programming Pointers 1 Purpose Pointers enable programs to simulate call-by-reference; to create and manipulate dynamic data structures, i.e. data structures that can grow and shrink,
More informationCOMP26120: Pointers in C (2018/19) Lucas Cordeiro
COMP26120: Pointers in C (2018/19) Lucas Cordeiro lucas.cordeiro@manchester.ac.uk Organisation Lucas Cordeiro (Senior Lecturer, FM Group) lucas.cordeiro@manchester.ac.uk Office: 2.44 Office hours: 10-11
More informationDay05 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 informationC++ Programming Chapter 7 Pointers
C++ Programming Chapter 7 Pointers Yih-Peng Chiou Room 617, BL Building (02) 3366-3603 ypchiou@cc.ee.ntu.edu.tw Photonic Modeling and Design Lab. Graduate Institute of Photonics and Optoelectronics & Department
More informationHomework #3 CS2255 Fall 2012
Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation
More informationExample: Pointer Basics
Example: Pointer Basics #include int (void) { float a1, a2; /* Simple variables */ float *p1, *p2, *w; /* Pointers to variables of type float */ a1 = 10.0, a2 = 20.0; printf("after a1 = 10.0;
More information