C expert programming Note 1

Source: Internet
Author: User

Chapter 1 C: crossing the fog of Time and Space
Ken Thompson created B Language; invented ++ and --;
Dennis Ritchie created "New B" and later renamed it C;
Specifically, UNIX appears earlier than C;

In the compiler, efficiency is almost everything;

The C language rejects strong types;

Which compiler designers are the major customers of C language in the past few years;

The auto keyword is obviously a decoration. It means "the memory is automatically allocated when the program block is entered" (opposite to the Global static allocation or heap allocation)

[Html]
Int f ()
Int;
{
Printf ("% d", );
}
 
Int main (){
Int a = 1;
F ();
 
Return 0;
}
The original function parameters can also be written like this;
The International confusing C Code Competition (The International Obfuscated C Code Competition)

Valve

The C programing language Brian Kernighan and Dennis Ritch;

If people write them in their daily languages, the more accurate they want to write them, the more likely they will become lengthy, boring, and obscure. If they use mathematical concepts to define language, the standard manual is not applicable to tianshu for most people;

You should not modify the language to deal with the restrictions of a specific platform;

In principle, the C language standard adopted by ANSI is iso c, and the Standard C we call should also be iso c;

[Cpp]
# Include <stdio. h>
# Include <limits. h>
Int main () {(void) printf ("biggest int is % d", INT_MAX); return 0 ;}

The standardization process attaches great importance to the form and seems rigid;
The adjacent string literal values are automatically connected together;

[Cpp]
Foo (const char ** p ){}
Int main (int argc, char ** argv)
{
Foo (argv );
}

The above code has a warning;
The whole process of obtaining this answer is more meaningful than simply knowing the conclusion;

The parameter passing process is similar to assigning values;

The value assignment must meet one of the conditions: the type pointed to by the Left pointer must have all the qualified words of the type pointed to by the right pointer;

Const char * refers to the type "pointing to a char type pointer with a const qualifier", that is, const limits the type pointed to by the pointer rather than the pointer itself;

The preceding Code has a warning that char ** is incompatible with const char;

Looking back, it would be much better to name the const keyword readonly;

[Cpp]
# Include <stdio. h>
Int array [] = {10, 0 };
# Define TOTAL_ELEMENTS (sizeof (array)/sizeof (array [0])
 
Int main (int argc, char ** argv)
{
Int d =-1;
 
If (d <= TOTAL_ELEMENTS)
Printf ("1 \ n ");
Else
Printf ("2 \ n ");
 
}

The output is 2, because sizeof returns the unsigned int. When the int type d and unsigned int are tested and compared, d is upgraded to unsigned int, So-1 is changed to that very large positive number;

From CodeBlog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.