C Language Common errors

Source: Internet
Author: User

Write the name of the main () function incorrectly, a C program must have a main () function, and case-sensitive.
The main () function forgot to return the value, normally the main () is written with an int as the return value, so in main () you need to return an integer data, the default return 0
The string in the printf () function is not enclosed in double quotation marks when writing a C program, characters other than the string contents should be entered using the English input method

Character form

Function

' \ r '

added a return key.

' \ n '

followed by a newline.

' \ t ' (table)

Tabs (with several spaces in the middle)

‘\\‘

Reverse Slash

‘ \‘ ‘

Single quotation marks

‘ \" ‘

Double quotes

' + '

Empty characters (not spaces)

/tr> /tr>

Identifiers

Output category

Example

Results

%d

Integral type

printf ("%d", 5);

5

%f

floating point

printf ("% F ", 5.5);

5.5

%. n

Floating-point number, reserved n decimal

printf ("%.2f", 3.1415926);

3.14

% m . N F

floating-point number retention N Decimal Place and before the decimal point with the total m bit alignment (M doesn't make sense)

printf ("%3.2f", 3.1415926);

3.14

%c

Character Type

printf ("%c", ' a ');

A

-for example a squared root minus B of the square root writing sqrt (a)-sqrt (b) sqrt () for the square root function-square pow (m,n)//number of N-square of a certain m. -the remainder of two numbers can be divided by using the% operator% also known as the modulo operator such as a% B (for two integer int, not for floating-point type)

C Language Common errors

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.