C++ for Mathematicians An Introduction for Students and Professionals phần 7

Đối với hầu hết các phần, toán học làm việc không liên quan đến thao tác dữ liệu ký tự. Tuy nhiên, nó rất hữu ích để có một hiểu biết chung về cách C + + xử lý dữ liệu nhân vật, làm thế nào để chuyển đổi văn bản đến các số, làm thế nào để sử dụng các đối số dòng lệnh, và làm thế nào để đọc và ghi dữ liệu trong các tập tin. | Chapter 14 Strings Input Output and Visualization For the most part mathematical work does not involve manipulation of character data. Nonetheless it is useful to have a general understanding of how C handles character data how to convert text to numbers how to use command line arguments and how to read and write data in files. We also show how to modify the formatting of output . how to increase the number of digits printed after the decimal point . We illustrate many of these ideas by creating a class to parse files one line at a time and break those lines into individual words. C has two ways to handle character data arrays of char values and in objects of type string. The char arrays are a legacy of C s roots in the C programming language. It is necessary to understand their basics but their use should be avoided where possible. The newer string variables are easier to use. We begin with a brief introduction to char arrays. Textual and numerical output are important but there are times when graphical output is especially insightful. We close this chapter with a discussion of how to draw pictures in C . Character arrays Character or text data consist either of individual characters letters numerals punctuation or of lists of characters. The C data type char holds a single character from the Latin character set 26 lower- and uppercase letters numerals white space punctuation . These are known as the ASCII characters and are the only characters with which this book deals. Computers can also deal with a richer set of glyphs from accented Latin letters to Chinese characters using a system called Unicode this system is beyond our scope. An ordered list of characters is generally called a character string. For example the words Hello Gauss are such a list comprising 11 characters. As mentioned C has two principal ways to work with character strings as null-terminated char arrays and as objects of the class string. The character array representation is a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
110    91    5    07-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.