









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Introduction to Computer Science II; Subject: Computer/Information Sciences; University: University of Delaware; Term: Unknown 1989;
Typology: Exams
1 / 15
This page cannot be seen from the preview
Don't miss anything!










Character stuff
old code treats as int or byte
character manipulation -
C strings
how are C strings stored?
how to declare a C string and variable?
string class in
can pass a C string to the constructor
takes care of the array size details so you don’t have to
basically a wrapper class - it effectively has a C string inside of it
overloaded operators
= copies the rvalue into the lvalue (and may resize the underlying C string in the lvalue)
and << work the same as C strings
overloaded []
can treat them like char[] if you want
doesn’t do bounds checking on array
function string.at(int) does the same thing, BUT checks bounds
string.length() returns the length
comparison operators
== compares the contents unlike C strings
<, <= , >, >= do alphanumeric comparisons
getting a C string version of a string (some functions require a C string) string.c_str()
memory can be treated like a gigantic array
a pointer is like an index to that array - it just specifies the position of some data
but... some data takes up multiple spots in memory
we still have the same index to the memory array, but some things take multiple spots
suppose we want to get the memory address of a variable, we use an &: cout << “Contents of addr “ << &x << “: “ << x << endl;
Note: this usage of & is different than the one we’ve seen so far
in declarations (params,defs,retvals) it signifies by reference
in other spots, it says to get the address
The two meanings of *
in declaring a variable/parameter/return value: signifies that it’s a pointer variable
in other situations: dereferences the variable (gets the stuff it points to)
expected length < period length
types of questions
what does this code do?
what does this error message mean?
find the bug in this code
write some simple code (5 lines max)
write a few good test cases