$ cd ~/cs35/labs $ git clone <link you got from github> ./lab05You should also update your examples repository by going in your examples directory and pulling the updated version of the repository
$ cd ~/cs35/examples/ $ git pull
$ cd ~/cs35/labs/lab05 $ ln -s /usr/local/doc/lab05-data/ ./test_data
Note the path /usr/local/doc/lab05-data/
is local only to the machines on the CS network and will not work if you clone your code to your personal computer.
We will first have a look at a few slides describing how to allocate an use 2D arrays. Then we will complete a few exercise in the ~/cs35/examples/week-06/2Darray folder.
int smallestPos(int* nums, int size){ int ans=-1; for( int i=0; i<size; i++){ if(nums[i] > 0){ if( (ans==-1) || (nums[i] < ans) ){ ans = nums[i]; } } return ans; }
$ cd ~/cs35/examples/ $ git pull
The above examples use C, but the program is mostly the same in cpp aside from some minor name changes for filename extensions, include headers, and compiler used. The cpp examples are in ~/cs35/examples/week-07/gdb/
~/cs35/examples/week-07/valgrind/
$ make $ valgrind ./simpletest