TAILIEUCHUNG - the ansi c programming phần 3

K&R C thường được xem là phần cơ bản nhất của ngôn ngữ mà nó cần phải có cho một trình dịch C. Trong nhiều năm, ngay cả sau khi ANSI C được giới thiệu, nó đã được xem như là "mẫu số chung nhỏ nhất" mà người lập trình C phải bám lấy nếu muốn có được khả năng dịch chuyển (tái dụng trên nhiều máy) bởi vì không phải mọi trình dịch đều hỗ trợ toàn bộ ANSI C, và một cách hợp lý là mã viết trong K&R C cũng là mã hợp lệ trong ANSI C | 43 expects a double argument and will produce nonsense if inadvertently handled something else. sqrt is declared in . So if n is an integer we can use sqrt double n to convert the value of n to double before passing it to sqrt. Note that the cast produces the value of n in the proper type n itself is not altered. The cast operator has the same high precedence as other unary operators as summarized in the table at the end of this chapter. If arguments are declared by a function prototype as the normally should be the declaration causes automatic coercion of any arguments when the function is called. Thus given a function prototype for sqrt double sqrt double the call root2 sqrt 2 coerces the integer 2 into the double value without any need for a cast. The standard library includes a portable implementation of a pseudo-random number generator and a function for initializing the seed the former illustrates a cast unsigned long int next 1 rand return pseudo-random integer on int rand void next next 1103515245 12345 return unsigned int next 65536 32768 srand set seed for rand void srand unsigned int seed next seed Exercise 2-3. Write a function htoi s which converts a string of hexadecimal digits including an optional 0x or 0X into its equivalent integer value. The allowable digits are 0 through 9 a through f and A through F. Increment and Decrement Operators C provides two unusual operators for incrementing and decrementing variables. The increment operator adds 1 to its operand while the decrement operator subtracts 1. We have frequently used to increment variables as in if c n nl The unusual aspect is that and -- may be used either as prefix operators before the variable as in n or postfix operators after the variable n . In both cases the effect is to increment n. But the expression n increments n before its value is used while n increments n after its value has been used. This means that in a context where the value is being used not just the

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.