tailieunhanh - Lecture Programming principles and practice using C++: Chapter 23 - Bjarne Stroustrup

This is the first chapter that’s focused on an application domain, rather than on a programming language features or a programming technique. Please make a big deal of that, because it is. Emphasize how the features and techniques we have learned by now come together to solve real-world problems: strings, iostreams, and maps, in particular. | Chapter 23 Text Processing Bjarne Stroustrup Overview Application domains Strings I/O Maps Regular expressions Stroustrup/PPP - Nov13 Now you know the basics Really! Congratulations! Don’t get stuck with a sterile focus on programming language features What matters are programs, applications, what good can you do with programming Text processing Numeric processing Embedded systems programming Banking Medical applications Scientific visualization Animation Route planning Physical design Stroustrup/PPP - Nov13 Text processing “all we know can be represented as text” And often is Books, articles Transaction logs (email, phone, bank, sales, ) Web pages (even the layout instructions) Tables of figures (numbers) Graphics (vectors) Mail Programs Measurements Historical data Medical records Stroustrup/PPP - Nov13 Amendment I Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or . | Chapter 23 Text Processing Bjarne Stroustrup Overview Application domains Strings I/O Maps Regular expressions Stroustrup/PPP - Nov13 Now you know the basics Really! Congratulations! Don’t get stuck with a sterile focus on programming language features What matters are programs, applications, what good can you do with programming Text processing Numeric processing Embedded systems programming Banking Medical applications Scientific visualization Animation Route planning Physical design Stroustrup/PPP - Nov13 Text processing “all we know can be represented as text” And often is Books, articles Transaction logs (email, phone, bank, sales, ) Web pages (even the layout instructions) Tables of figures (numbers) Graphics (vectors) Mail Programs Measurements Historical data Medical records Stroustrup/PPP - Nov13 Amendment I Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the government for a redress of grievances. String overview Strings std::string () s1==s2 C-style string (zero-terminated array of char) or strlen(s) strcmp(s1,s2)==0 std::basic_string, . Unicode strings using string = std::basic_string; Proprietary string classes Stroustrup/PPP - Nov13 C++11 String Conversion In , for numerical values For example: string s1 = to_string(); // "" string s2 = to_string(1+5*6-99/7); // "17" Stroustrup/PPP - Nov13 String conversion We can write a simple to_string() for any type that has a “put to” operator string to_string(const T& t) { ostringstream os; os C++11 String Conversion Part of , for numerical destinations For .