CSCI 10 Lecture 15: CSCI 10 – Day 15
Premium

2 Pages
98 Views

Department
Computer Science
Course Code
CSCI 10
Professor
Bannister

This preview shows half of the first page. Sign up to view the full 2 pages of the document.
CSCI 10 Day 15
MORE WITH STRINGS
Announcements:
-Homework 5 is due next Friday
-Challenge problems are included with assignments, but not graded
-Midterm in one week! Topics covered: Advanced loops, functions, scope, call-by-
reference, simple arrays (reading, writing, no algorithmic stuff)
LECTURE
Random talk about the DDos attack
DNS Server (the dot) .com, .edu, .org
-Dyn was attacked by DDos; Twitter, GitHub, and many other were hosted
under Dyn
-It’s just a showoff…money is involved
Webpages was not designed to be interactive…but we made it so
Objects!!!!!!
An object contains encapsulated data (local variables) and procedures
(functions/methods) grouped together to represent a single entity.
C++ Strings vs C-Strings
C++ Strings are objects that come with all the associated automated
memory management and control which makes them a lot safer and
easier to use, thus it can increase automatically
C-Strings are just arrays, which means that you, the programmer, are
responsible
C++ strings are much safer,easier,and they support different string
manipulation functions like append,find,length,copy,concatenation,
substr, etc.
You can compare two C++ strings directly using the equality operator ==
; You can’t do this with C-Strings because you would be comparing
pointers, not the array of characters. You can only use strcmp() for C-
strings and its return values are very counterintuitive…
Operator overloading,
C++ strings include whitespaces
Comparison operators (>, <) depends on lexicographical order (B > A, C >
B, etc.)
substr(pos, len)
Use .at(index) to get a character in a c++ string
Why can’t you use arr[-1] in C/C++?
Youre simply getting a pointer that contains the address of that "imaginary"
location, i.e. the location of the first element &realarray[0] minus the size of one
element.
This is undefined behavior, and might break horribly if, for instance, your
machine has a segmented memory architecture. It's working because the
compiler writer has chosen to implement the arithmetic as outlined above; that
find more resources at oneclass.com
find more resources at oneclass.com

Loved by over 2.2 million students

Over 90% improved by at least one letter grade.

Leah — University of Toronto

OneClass has been such a huge help in my studies at UofT especially since I am a transfer student. OneClass is the study buddy I never had before and definitely gives me the extra push to get from a B to an A!

Leah — University of Toronto
Saarim — University of Michigan

Balancing social life With academics can be difficult, that is why I'm so glad that OneClass is out there where I can find the top notes for all of my classes. Now I can be the all-star student I want to be.

Saarim — University of Michigan
Jenna — University of Wisconsin

As a college student living on a college budget, I love how easy it is to earn gift cards just by submitting my notes.

Jenna — University of Wisconsin
Anne — University of California

OneClass has allowed me to catch up with my most difficult course! #lifesaver

Anne — University of California
Description
find more resources at oneclass.com CSCI 10 – Day 15 MORE WITH STRINGS Announcements: -Homework 5 is due next Friday -Challenge problems are included with assignments, but not graded -Midterm in one week! Topics covered: Advanced loops, functions, scope, call-by- reference, simple arrays (reading, writing, no algorithmic stuff) LECTURE Random talk about the DDos attack  DNS Server (the dot)  .com, .edu, .org  -Dyn was attacked by DDos; Twitter, GitHub, and many other were hosted under Dyn  -It’s just a showoff…money is involved  Webpages was not designed to be interactive…but we made it so Objects!!!!!!  An object contains encapsulated data (local variables) and procedures (functions/methods) grouped together to represent a single entity. C++ Strings vs C-Strings  C++ Strings are objects that come with all the associated automated memory management and control which makes them a lot safer and easier to use, thus it can increase automatically  C-Strings are just arrays, which means that you, the programmer, are responsible  C++ strings are much safer,easier,and they support different string manipulation functions like append,find,lengt
More Less
Unlock Document


Only half of the first page are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit