Expert c programming

290 203 0
Expert c programming

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Đây là bộ sách tiếng anh cho dân công nghệ thông tin chuyên về bảo mật,lập trình.Thích hợp cho những ai đam mê về công nghệ thông tin,tìm hiểu về bảo mật và lập trình.

[...]... *src); You can also omit the names of the parameters, leaving only the types: char * strcpy(char * , const char * ); Don't omit the parameter names Although the compiler doesn't check these, they often convey extra semantic information to the programmer Similarly, the definition of the function has changed from char * strcpy(dst, src) char *dst, *src; { } to char * strcpy(char *dst, const char *src) /*... assigned to the implicitly declared floating point variable DO10I The statements in the body of the intended loop were executed once instead of ten times, and a first approximation of a calculation took place instead of an iterative convergence After cor-recting the period to a comma, the results were correct to the expected accuracy The bug was detected in time and never caused a Mercury space flight to fail... function name and return value type) when we make a forward declaration of a function The compiler can thus check the types of arguments in a function call against the way the parameters were defined In K&R C, this check was deferred till link time or, more usually, omitted entirely Instead of char * strcpy(); declarations in header files now look like this: char * strcpy(char *dst, const char *src);... legal because in the code char * cp; const char *ccp; ccp = cp; • • • The left operand is a pointer to "char qualified by const" The right operand is a pointer to "char" unqualified The type char is a compatible type with char, and the type pointed to by the left operand has all the qualifiers of the type pointed to by the right operand (none), plus one of its own (const) Note that the assignment cannot... pragma directive was introduced Borrowed from Ada, #pragma is used to convey hints to the compiler, such as the desire to expand a particular function in-line or suppress range checks Not previously seen in C, pragma met with some initial resistance from a gcc implementor, who took the "implementation-defined" effect very literally—in gcc version 1.34, the use of pragma causes the compiler to stop compiling... Competition, a whimsical contest in which programmers try to outdo each other in inventing mysterious and confusing programs (more about this competition later) Macro use is best confined to naming literal constants, and providing shorthand for a few well-chosen constructs Define the macro name all in capitals so that, in use, it's instantly clear it's not a function call Shun any use of the C preprocessor that... Chapter 7 Runtime checking goes against the C philosophy that the programmer knows what he or she is doing and is always right The cases and the default can come in any order, though by convention the default case is usually the last one A conformant C compiler must permit at least 257 case labels for a switch statement (ANSI C Standard, section 5.2.4.1) This is to allow a switch on an 8-bit character... very first footnote, which refers to the accompanying Rationale document In fact, the Rationale no longer accompanies the C Standard—it was deleted when ownership of the standard moved to ISO Handy Heuristic Differences between K&R C and ANSI C Rest assured that if you know K&R C, then you already know 90% of ANSI C The differences between ANSI C and K&R C fall into four broad categories, listed below... respectively The following sections describe C features in these categories This chapter isn't meant as fatal criticism of C C is a wonderful programming language with many strengths Its popularity as the implementation language of choice on many platforms is well-deserved But, as my grandmother used to say, you can't run a super-conducting supercollider without smashing a few atoms, and you can't... switch statement is: switch (expression){ case constant-expression: zero-or-more-statements default: zero-or-more-statements case constant-expression: zero-or-more-statements } Each case is introduced by triplets of the keyword case, followed by an integer-valued constant or constant expression, followed by a colon Execution starts at the case that matches the expression The default case (if present) can .

Ngày đăng: 19/03/2014, 13:33

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan