Get 1 week of unlimited access
Class Notes (1,051,497)
US (414,407)
CSCI (23)
CSCI 10 (18)
Lecture 13

CSCI 10 Lecture Notes - Lecture 13: Stack Buffer OverflowPremium

2 pages37 viewsFall 2016

Department
Computer Science
Course Code
CSCI 10
Professor
Bannister
Lecture
13

This preview shows half of the first page. to view the full 2 pages of the document.
CSCI 10 Day 13
ARRAYS!
Announcements
-HW 4 due Friday
LECTURE
Example 22
-Array basics: creating, reading, writing, priting, copying
-An array doesn’t know its size…it doesn’t know how many entries it is
responsible for.
-The old standard should be a constant variable that holds the array size
-Now we can ask the user to input to the size variable to specify size of the
array
-Array size cannot be changed once initialized in C++ (by only replacing
the array can you change the content of the array)
int main () {
const int sz = 10; //size variable
int A[sz];
for (int i = 0; i < 10; i++) A[i] = 0;
B = A; // invalid array assignment
return 0;
}
// find min in array
int smallest = nums[0];
for (int i = 1; i < N; i++) {
if (nums[i] < smallest) {
smallest = nums[i];
}
}
cout << smallest << endl;
How to sort an array:
Find the biggest, and swap it with the very last entry in the array, repeat
the process with the rest of the array (except arr[-1])
-The
-Any function that takes an array must also take a size parameter
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version

Subscribers Only

Loved by over 2.2 million students

Over 90% improved by at least one letter grade.