TAILIEUCHUNG - Thinking in c volume 1 - 2nd edition - phần 4

việc thử nghiệm được xây dựng trong khả năng thiết kế của ngôn ngữ chỉ có thể đi xa. Tại một số điểm, bạn phải bước vào và thêm phần còn lại của các bài kiểm tra sản xuất một bộ đầy đủ (hợp tác với các trình biên dịch và hệ thống thời gian chạy) kiểm tra tất cả các chương trình của bạn. Và, giống như có một trình biên dịch xem trên của bạn | After each Stash is loaded it is displayed. The intStashis printed using a for loop which uses count to establish its limit. The stringStashis printed with a while which breaks out when fetch returns zero to indicate it is out of bounds. You ll also notice an additional cast in I cp char fetch stringStash i This is due to the stricter type checking in C which does not allow you to simply assign a void to any other type C allows this . Bad guesses There is one more important issue you should understand before we look at the general problems in creating a C library. Note that the file must be included in any file that refers to CStash because the compiler can t even guess at what that structure looks like. However it can guess at what a function looks like this sounds like a feature but it turns out to be a major C pitfall. Although you should always declare functions by including a header file function declarations aren t essential in C. It s possible in C but not in C to call a function that you haven t declared. A good compiler will warn you that you probably ought to declare a function first but it isn t enforced by the C language standard. This is a dangerous practice because the C compiler can assume that a function that you call with an int argument has an argument list containing int even if it may actually contain a float. This can produce bugs that are very difficult to find as you will see. Each separate C implementation file with an extension of .c is a translation unit. That is the compiler is run separately on each translation unit and when it is running it is aware of only that unit. Thus any information you provide by including header files is quite important because it determines the compiler s 244 Thinking in C www. BruceEckel .com understanding of the rest of your program. Declarations in header files are particularly important because everywhere the header is included the compiler will know exactly what to do. If for example you have

TỪ KHÓA LIÊN QUAN
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.