Notes for using IDE To write C language programs, ide to write C Language Programs

Source: Internet
Author: User

Notes for using IDE To write C language programs, ide to write C Language Programs

  I am a cainiao who likes programming. During the course of self-study, I have some questions and confusions. Although I have some experience, I will forget it for a long time, it is not conducive to the accumulation of knowledge. Therefore, I want to record my learning experience through the blog Park platform. I also want to consult with many experts.

 

I recently learned the C language, mainly using C-Free. In the course of learning, I found that the C language must follow a certain writing method, But the strange thing is that it can also be compiled without such writing.

Run the following code:

1 #include <stdio.h>
  2 
  3 struct point / * define structure * /
  4 {
  5 int x;
  6 int y;
  7};
  8 
  9 int main (int argc, char * argv [])
10 {
11 struct point A;
12 A.x = 2;
13 A.y = 3;
14 printf ("The coordinates of point A are: [% d,% d] \ n", A.x, A.y);
15 return 0;
16} 

As mentioned in the book: Line 1 must be written as struct point A rather than point. However, the compilation was successful, and later it was tested with VC ++ 6.0. Because I read two books at the same time for self-study, both of them are written in this way, and I believe the books should be correct. After several attempts, it is found that the default file extension is incorrect.

  C-Free and VC ++ 6.0 are compiled based on the source file extension. If the source file extension is. c, it is considered as the C language source file for compilation; if the source file extension is. cpp, it is considered as the c ++ source file for compilation.C-Free and VC ++ 6.0 default source file extensions are. cpp, the compiler is regarded as a C ++ source file for compilation, and C ++ allows the keyword struct to be omitted when declaring a struct, so compilation can be successful.


If you change the source file extension to. c when saving the file, or modify the default extension, the c language source file will be compiled. The keyword struct cannot be omitted in C language, so an error is prompted during compilation. So,When learning c language, you should set the default extension of IDE to. c, or save it as a. c file before compiling to avoid unnecessary confusion.


 


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.