{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

proj4

proj4 - − 1 if they are passed any bad arguments(e.g a...

This preview shows pages 1–5. Sign up to view the full content.

Project 4 Write (many) short functions. Each function either modifies the array(s) you are given, returns a value based on the given array(s), (or both)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Project 4 int tally(const string a[], int n, string target); a is the array of strings n is the number of elements in the array We need this information, since there is no way you can figure out how many elements there are without explicitly getting the value. Since the array is declared to be const , you cannot modify this array.
Project 4 int moveToEnd(string a[], int n, int pos); This function requires you to modify a[] . Interestingly, if you modify a[] , the changes will be reflected outside the function. That is, after the following function call (in main() ), int x = moveToEnd(myArray, 10, 3); myArray will be changed. We will see why this is the case when we talk about pointers.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Project 4 “Notwithstanding each function's behavior described below, all functions that return an int must return
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: − 1 if they are passed any bad arguments (e.g. a negative array size, or a position that would require looking at the contents of an element past the last element we're interested in). Unless otherwise noted, passing to the function an array size of 0 is not an error; it merely indicates the function should examine no elements of the array.” • If the arguments are bad, return -1. – Array size (n) is negative. – The array size (n) and a position (pos) are specified, and the position is out of bounds (i.e., pos is not in [0, n-1]). – Array size of 0 is not an error unless otherwise specified. Project 4 • “The one error your function implementations don't have to handle, because they can't, is when the caller of the function lies and says the array is bigger than it really is.” • Do not worry about the case where n is greater than the actual size of a ....
View Full Document

{[ snackBarMessage ]}

Page1 / 5

proj4 - − 1 if they are passed any bad arguments(e.g a...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online