Beginning Visual C++® 2005 (P4)

Tham khảo tài liệu 'beginning visual c++® 2005 (p4)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Arrays Strings and Pointers The argument is the name of the array containing the string and the strlen function returns the length of the string as an unsigned integer of type size_t. Many standard library functions return a value of type size_t and the size_t type is defined within the standard library using a typedef statement to be equivalent to one of the fundamental types usually unsigned int. The reason for using size_t rather than a fundamental type directly is that it allows flexibility in what the actual type is in different C implementations. The C standard permits the range of values accommodated by a fundamental type to vary to make the best of a given hardware architecture and size_t can be defined to be the equivalent the most suitable fundamental type in the current machine environment. Finally in the example the string and the character count is displayed with a single output statement. Note the use of the escape character to output a double quote. Multidimensional Arrays The arrays that you have defined so far with one index are referred to as one-dimensional arrays. An array can also have more than one index value in which case it is called a multidimensional array. Suppose you have a field in which you are growing bean plants in rows of 10 and the field contains 12 such rows so there are 120 plants in all . You could declare an array to record the weight of beans produced by each plant using the following statement double beans 12 10 This declares the two-dimensional array beans the first index being the row number and the second index the number within the row. To refer to any particular element requires two indices. For example you could set the value of the element reflecting the fifth plant in the third row with the following statement beans 2 4 Remember that the index values start from zero so the row index value is 2 and the index for the fifth plant within the row is 4. Being a successful bean farmer you might have several identical .

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
544    177    5    21-06-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.