Class Notes (1,051,408)
US (414,376)
CSCI (23)
CSCI 10 (18)
Lecture 15

CSCI 10 Lecture Notes - Lecture 15: Github, Undefined Behavior, C String HandlingPremium

2 pages104 viewsFall 2016

Computer Science
Course Code

This preview shows half of the first page. to view the full 2 pages of the document.
CSCI 10 Day 15
-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)
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
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
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
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
find more resources at
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.