Reading for L3: Chapter 10, Chapter 5, Section 4. Reading for L4: Chapter 6.1 Lecture 3: (06/13/2006) Part I: PARALLEL ARRAYS, MULTIDIMENSIONAL ARRAYS ================================================ (1) What are parallel arrays? What are multidimensional arrays? (2) Is there a "better" way to do what parallel arrays do? Part II: POINTERS AND ADDRESSES ================================ 1) Pointers and Addresses are just like arrays. Think of Memory as one big array with about 4 billion elements. To be precise: two to the 31st power minus 1 elements (about 4 billion) 31 2 - 1 2) Some pointer examples: int *yPtr; int y=25; *yPtr=y; or yPtr=&y; Let's do display 10.2 from the text, page 428. Also, do http://www.cis.udel.edu/~cfischer/cisc18106S/ptrbyvalue.cc and http://www.cis.udel.edu/~cfischer/cisc18106S/new.cc Before we can truly understand this or investigate it in code, we need to understanding binary, octal, hexadecimal and decimal. So: 38 base 10 is _______________ base 2 64 32 16 8 4 2 1 0 1 0 0 1 1 0 13 base 16 is ___________ base 2 1x16 + 3x1 = 19 base 10 1 3 base 16 0001 0011 base 2 answer is 0001 0011 equally valid answer: 00010011 equally valid answer: 10011 Practice these at: http://www.udel.edu/CIS/105/pconrad/05F/examInfo/E03_practiceQuiz/quiz2.html 22 base 8 is ___ 010 010 ____________ base 2 which is _________ base 10 0 x 2^5 + 1 * 2^4 + 0 * 2^3 + 0 * 2^2 + 1 * 2^1 = 16 + 2 = 18 2 * 8^1 + 2 * 8^0 = 2 * 8 + 2 = 16 + 2 = 18 B15 base 16 is __ 1011 0001 0101 ____ base 2 Now: give me groups of 4 bits 0110 1001 0110 0000 1000 1111 0101 0100 6 9 6 0 8 f 5 4 D C 2 B 7 1 6 9 1101 1100 0010 1011 0111 0001 0110 1001 1011 0010 Let's convert these: 0110 1001 6 9 0000 0001 0 1 0100 0010 4 2 1010 1011 a b 1111 1110 f e 1100 1101 c d 83 base 10 = 1010 0011 base 2 0101 0011 64 16 3 == 83 C47 base 16 = 1100 0100 0111 base 2 74 base 8 = 111 100 base 2 = 60 base 10 21B base 16 = 0010 0001 1011 base 2 4) Let's do address*.cc! PART III. COMMA SEPARATED FILES =============================== (1) CSV files: what's the big deal? (2) Arrays of structs. Let's do example readWorkoutData.cc. (3) Dynamic memory allocation: not wasting the space when names are short having enough room when names are long. ALERT: malloc/free in C.... new/delete in C++