Đang chuẩn bị liên kết để tải về tài liệu:
the ansi c programming phần 7

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Unix nguyên đã được phát triển để tạo ra một hệ thống tự động lập hồ sơ cho các bằng phát minh. Phiên bản đầu tiên của Unix đã phát triển từ ngôn ngữ Assembly. Sau đó, ngôn ngữ C đã được phát triển để từ đó thay thế hệ điều hành mới. | 127 arguments of if they are the wrong type. You should also be aware of the difference between these two calls printf s FAILS if s contains printf s s SAFE The function sprintf does the same conversions as printf does but stores the output in a string int sprintf char string char format arg1 arg2 . sprintf formats the arguments in arg1 arg2 etc. according to format as before but places the result in string instead of the standard output string must be big enough to receive the result. Exercise 7-2. Write a program that will print arbitrary input in a sensible way. As a minimum it should print non-graphic characters in octal or hexadecimal according to local custom and break long text lines. 7.3 Variable-length Argument Lists This section contains an implementation of a minimal version of printf to show how to write a function that processes a variable-length argument list in a portable way. Since we are mainly interested in the argument processing minprintf will process the format string and arguments but will call the real printf to do the format conversions. The proper declaration for printf is int printf char fmt . where the declaration . means that the number and types of these arguments may vary. The declaration . can only appear at the end of an argument list. Our minprintf is declared as void minprintf char fmt . since we will not return the character count that printf does. The tricky bit is how minprintf walks along the argument list when the list doesn t even have a name. The standard header stdarg.h contains a set of macro definitions that define how to step through an argument list. The implementation of this header will vary from machine to machine but the interface it presents is uniform. The type va_list is used to declare a variable that will refer to each argument in turn in minprintf this variable is called ap for argument pointer. The macro va_start initializes ap to point to the first unnamed argument. It must be called once before ap is used.