CS 106B Lecture Notes - Lecture 2: Function Prototype, C String Handling, String Literal

36 views4 pages

Document Summary

Extra office hours with megan @ gate 104, 10am-11am. Most operators and control flow is the same. Need to #include string s = hello ; A string is a possibly empty sequence of characters. Strings in c++ are conceptually similar to java strings. You can concatenate strings using + or += Unlike java, you can compare strings using relational operators string s2 = megan ; if (s2 >s1 && s2 != keith ){ Unlike java, strings are mutable s1. append( piech ) s1. erase(3, 2) C strings (any string literal such as hi there is a c string. String s = hi + there ; (does not compile) N is now memory address of c string. String s = hi + ?"; string s = hi + 41 (produces garbage) String s = hi ; s+=41; (adds ascii value of 41)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents