CS 161 Lecture Notes - Lecture 17: C String Handling, Dynamic Array

36 views3 pages

Document Summary

Cs 161 lecture 17 multidimensional arrays. Minor corrections: char arrays which are null terminated are c-style strings, that means you can use functions from (string. h) on them, char arrays do not need to be null terminated. Int mult_table[5][5]: char cross_word[15][15, float grades[num_students][num_grades, example of multidimensional problem, 2d, chess, orthello, minesweeper, 3d rubics cube, 4d (x, y, z, t) Initializing 2d arrays: declaration: int arr[2][3] = {{0,0,0}, {0,0,0}, rows, columns. Individual elements: arr[0][0] = 0, arr[0][1] = 0, arr[0][2] = 0, arr[1][0] = 0, loop, for (int i=0; i<2; i++) , for int j=0; j<3; j++) , arr[i][j] = 0; }} Dynamic 2d arrays: 1d dynamic array, points to a row on the heap, 2d dynamic array, points to a column that points to rows on the heap. Int ** ar: ar = new int*[rows], for (int i=0; i

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers