C Primer Plus reading notes chapter II

Source: Internet
Author: User

The title of this chapter is a C language overview, which is about some simple sample programs to understand and familiarize yourself with some of the basic features of C language.

This is the first piece of code in the book, knocking and looking for feelings. It is recommended to write code in a Linux environment.

PS: Daoteng Sublime text One afternoon, want to install a Sumblimeclang plug-in, the results directly to the sublime text collapse, anger for Atom, with a good.

#include <stdio.h>int main (void)/   * A simple C program */{    int num;     /* defined as a variable named num */    num = 1;     /* Assign value *    /printf ("I am a simple"); /* Use the printf () function */    printf ("computer.\n");    printf ("My favorite number is%d because it is first.\n", num);    return 0;}

The code is simple. The following 2.2-section example illustrates very detailed. Good for beginners to read again and again.

Attention:

1. #include不是C语言的语句, #符号表示这一行是在编译器接手前由C预处理器处理的语句.

2. Traditionally, the C language requires that a variable be declared at the beginning of a block of code, in which no other statement is allowed. Now C99 follows the C + + principle, allowing the declaration to be placed anywhere in the code. However, many compilers do not support the C99 rule.

3. Tips for making the program readable: 1. Select a meaningful variable name. 2. Use annotations. 3. Use a blank line to separate the concept of a function from multiple parts. 4. One line.

The third example code in the book is as follows

#include "stdio.h" Void Butler (void); /* Iso/ansi C function prototype */int main (void) {    printf ("I'll summon the butler funtion.\n");    Butler ();    printf ("Yes, bring me some tea and writeable cd-roms.\n");    return 0;} void Butler (void) {    printf ("You Rang, sir?\n");}

The C90 standard adds a prototype, which is a declarative form that tells the compiler that you are using a special function and indicating the properties of the function. C Standard Recommended function prototypes for all functions to be used.

Debugger methods: 1. Step-by-step tracking procedures. 2. Add additional printf () statements to key places. 3. Use the debugger.

After-school exercises are all about printf (), no difficulty.

To be Continued ...

C Primer Plus reading notes chapter II

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.