The modern method of C language programming

Source: Internet
Author: User

1: Floating-point (float) operation is slower than int and may have rounding errors

such as float storage 0.1, later use may become 0.099999999987

2: Macros are defined only in uppercase, which is the norm for most C program apes to follow!

The C language is case-sensitive and basically follows the specification of using only lowercase letters in identifiers

Such as: Symboltable,currentpage said, sometimes can also symboltable, currentpage

3:GCC has multiple command-line options to control how thoroughly the check is done

-wall causes the compiler to generate a warning message when it checks for possible errors. Used in conjunction with-O

-W In addition to the warning messages generated by-wall, additional warning messages are required for specific situations

-pedantic production of warning messages in accordance with the requirements of the C standard to avoid nonstandard features in the program

-ansi disables non-standard GCC features and enables some less commonly used standard features

-std=c89 or-STD=C99 indicates which version of the C compiler to use to check the program

4: According to the C standard, the compiler must replace each comment statement with an empty characters

such as: a/**/b=0;

Might turn out to be a b=0 error.

5:

#include <stdio.h>intMainvoid){    inti; floatx; I= +; X=839.21f; printf ("|%d|%5d|%-5d|%5.3d|\n", I,i,i,i); printf ("|%10.3f|%10.3e|%-10g|\n", x,x,x); return 0;//take note of the empty line's retention point}

Output these things, minus sign left aligned, plus right align

6: Escape character

\ nthe line break

\ t watchmaking

\b Backspace

\ r Enter

\ \ = backslash "\"

\ ' denotes single quotation marks

\ "denotes double quotation marks

\DDD characters represented by 1 to 3-bit octal

\XHH characters represented by 1 to 2 hexadecimal digits

printf ("\" hello!\ ""); output "hello!"

C Language Programming modern methods--------

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.