I also want to learn C language-Chapter 2: The initial compilation SOLUTION OF THE FIRST C program

Source: Internet
Author: User

The last time I learned how to successfully run the first C program under vc6.0, I felt excited. but with regard to compilation, links, and other steps, vc6.0 has helped me with it, and I feel it is really convenient, but this has brought me a problem, the steps are just reading books and learning about yourself. I have never practiced it, so I feel that I am not my own things. So I decided to write a program using notepad, but I had to compile the program and link it to VC.

First, I wrote the helloworld program in notepad.

#include<stdio.h>

int main(void)
{
printf("Hello,World!\r\n");

return (0);
}

Then, name the file suffix "Hello. c" as the. c file.

Then in cmd, when Cl hello. C is used, the CL compiler will generate two files. 1 is the hello.exe file, and 1 is the hello. OBJ file .. I know that the EXE file is an executable file on the Windows platform, but what is this. OBJ file? I don't understand it. I checked the information. Originally, the. OBJ file is in the common coff format and is a target file. It can interact with other platforms. But how can I suddenly see two files! Originally, the CL command was used directly, and the compiler gave the automatic link. Here we need to add 1 parameter/C. In this way, the compiler will not automatically link. Well! After the parameter/C is added, only one. OBJ file exists !!! Now there is no. execommand to generate the. exe file. Another command tool is used here. Link. This tool is the linker! Then I will do this: link hello. obj. The link is used to create a petabyte-style hello.exe for the winplatform. Hey hey! Now you can run the hello program on the win platform !!!

In the previous section, a user reminded me that # include <stdio. h> is to expand the stdio. h file as is here. So I thoroughly studied and proved his statement. Yes, thank you very much! But how can we see this process on our own. Add two parameters/C and/P after the CL command. I will try it! In this case, one. I file is added. Then I opened it, and there were more than 400 lines. I checked the stdio carefully. the content in H is the same, but one of the details is stdio. other files are included in the H file, so more than 400 lines are displayed after all the files are expanded!

Well! Now I almost understood how the first program was done!

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.