Clicker -- 01 - Big O Review if you get around to it.
- First day of class -- just have the policies page on the ipad (https://web.eecs.utk.edu/~jplank/General-Teaching/Policies.html) - Office Hours ------------------------------------------------------------ Eye rolling about me being old. C Style Strings: Specify what they are. - Two issues -- it is a convention. -- you need to make sure that there is room for the NULL character. Go over src/c_str.cpp -- buf[10], str = buf, cpps = buf. ------------------------------------------------------------ C++ strings -- heavyweight data structure. Talk about push_back().... c_str() method. Look at, or right src/buffer_changes -- 10000 push_backs, checking c_str() each time. Messing with c-str() -- look at bad_c_str(). Setting s[1] = '\0'; ------------------------------------------------------------ sprintf -- doing printf into strings -- gotta make sure the buffer is big enough. Check out src/sprintf2 -- what happens when the buffer isn't big enough. ------------------------------------------------------------ Disaster code: src/bad_c_str_2.cpp. ------------------------------------------------------------ Sscanf1: s = "100" read it and print it. Next: sscanf2: getline; n = sscanf(s.c_str(), "%lf %d", d, i) - print n, d, i. echo 10.5 5 | a.out echo 10.5 Fred | a.out echo Fred 5 | a.out echo 10.5xyz 55 | a.out echo go vols | a.out sscanf3: Don't have to be spaces - just show them %d:%d:%d -- handy for lab 1. ------------------------------------------------------------ snprintf(). Why is c_str() bad in sprintf but good in sscanf?