Introduction To Computer Science PDF Fall 2024
Document Details
Uploaded by FervidDune
ETH Zurich
2024
Manuela Fischer and Felix Friedrich
Tags
Related
- Fundamentals of Python: First Programs - Strings and Text Files PDF
- Java Programming Fifth Edition - Characters, Strings, and the StringBuilder PDF
- Java Strings Learning Sheet - Programming 1 PDF
- Chapter 3 Computer Science 12 - Federal Board PDF
- CSM-2170 Chapter 8 (Strings) PDF
- Lecture 8: Characters and Texts PDF
Summary
Lecture notes for Introduction to Computer Science, Fall 2024, from ETH Zurich. The document covers characters and texts in programming..
Full Transcript
INTRODUCTION TO COMPUTER SCIENCE 252-0032, 252-0047, 252-0058 Document authors: Manuela Fischer and Felix Friedrich Department of Computer Science, ETH Zurich Fall 2024 1 Characters and Texts...
INTRODUCTION TO COMPUTER SCIENCE 252-0032, 252-0047, 252-0058 Document authors: Manuela Fischer and Felix Friedrich Department of Computer Science, ETH Zurich Fall 2024 1 Characters and Texts 128 Section 10 Characters and Texts We have seen texts before: std::cout 0 // POST: returns the mathematically defined remainder of // dividend / divisor with 0 = 32 && c > std::noskipws; // #include char next; while (std::cin >> next){ std::cout > s; // Shift input by s caesar(s); return 0; } Code 10.1: Reading a shift value and a text from standard input and writing the encoded text to standard output. Comparing texts: if (text1 == text2)... true if character-wise equal Querying size: int length = text.size(); Characters and Texts 132 Size not equal to text length if multi-byte encoding is used, e.g. UTF-8 Reading single characters: if (text == 'a')... //or text.at(0) text does not check index bounds, whereas text.at(0) does Writing single characters: text = 'b'; //or text.at(0) Iteration over characters: for (int i = 0; i < int(text.size()); ++i) std::cout