TAILIEUCHUNG - D Programming Language PHẦN 9

của một ổ đĩa. char [] defaultExt (char [] họ tên, char [] ext) Đặt một phần mở rộng mặc định trên họ tên nếu nó không đã có một phần mở rộng. char [] addExt (char [] họ tên, char [] ext) Thêm tập tin mở rộng hoặc thay thế phần mở rộng hiện có. int isabs (char [] đường dẫn) Xác định tên đường dẫn tuyệt đối. | The D Programming Language The D Way D supports dynamic arrays which can be easilly resized. D supports all the requisite memory management. int array array x String Concatenation The C Way There are several difficulties to be resolved like when can storage be free d dealing with null pointers finding the length of the strings and memory allocation include char s1 char s2 char s Concatenate si and s2 and put result in s free s s char malloc si strlen si 0 s2 strlen s2 0 1 if s error out of memory if s1 strcpy s si else s 0 if s2 strcpy s strlen s s2 Append hello to s char hello hello char news size_t lens s strlen s 0 news char realloc s lens sizeof hello 1 sizeof char if news error out of memory s news memcpy s lens hello sizeof hello The D Way D overloads the operators and for char and wchar arrays to mean concatenate and append respectively char si char s2 char s s si s2 s hello 185 The D Programming Language Formatted printing The C Way printf is the general purpose formatted print routine include printf Calling all cars d times n ntimes The D Way What can we say printf rules import stdio printf Calling all cars d times n ntimes Forward referencing functions The C Way Functions cannot be forward referenced. Hence to call a function not yet encountered in the source file it is necessary to insert a function declaration lexically preceding the call. void forwardfunc void myfunc forwardfunc void forwardfunc . The D Way The program is looked at as a whole and so not only is it not necessary to code forward declarations it is not even allowed D avoids the tedium and errors associated with writing forward referenced function declarations twice. Functions can be defined in any order. void myfunc forwardfunc void forwardfunc . Functions that have no arguments The C Way void function void The D Way D is a strongly typed language so there is no need to explicitly say a function takes no arguments just don t declare it has having arguments. .

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.