Use the IDE to make your code style look good

Source: Internet
Author: User

Some novice code is not aware of the style, the code is not aligned indentation, such as the following code

#include <stdio.h>intMainvoid){    intI,n;ints =0; while(SCANF ("%d", &n)! =EOF) { for(i=1; i<=n;i++) s+=i;printf ("%d\n", s);} return 0;}

Visual C + +:

First, select all of your code (the form where the code is located, the shortcut key with CTRL + A), and then press ALT + F8 to get the following style code

#include <stdio.h>intMainvoid){        intI,n; ints =0;  while(SCANF ("%d", &n)! =EOF) {         for(i=1; i<=n;i++) s+=i; printf ("%d\n", s); }     return 0;}

Codeblocks:

Click on the right mouse button in the Code window and a menu appears, click "Format use Astyle".

Get the code of the following style

#include <stdio.h>intMainvoid){    intI,n; ints =0;  while(SCANF ("%d", &n)! =EOF) {         for(i=1; i<=n; i++) s+=i; printf ("%d\n", s); }    return 0;}

Generally speaking, Astyle is much more powerful, and can be customized in style. For example, the following code, VC + + 6.0 is not processed, and CB is very good

#include <stdio.h>intMainvoid){        intI,n; ints =0;  while(SCANF ("%d", &n)! = EOF) { for(i=1; i<=n;i++) s+=i; printf ("%d\n", s); }     return 0;}

Use the IDE to make your code style look good

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.