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. .