Compile together GCC files in linux

Source: Internet
Author: User
In linux, GCC files are compiled together-general Linux technology-Linux programming and kernel information. The following is a detailed description. Do you know how to compile a few files with gcc? If you don't know, you can take a look. If you know, please give me some advice. This is a teacher's class exercise, the purpose is to familiarize us with how to compile the file together under the gcc of linux.

The question is very simple, that is, entering a floating point and then outputting the square

/* Calc. c file */
# Include
# Include "sq. h"
# Include "printout. h"
Int main ()
{
Float f;
While (scanf ("% f", & f ))
{
Pout (squre (f ));
}
Return 0;
}

/* Printout. h file */
# Include
Void pout (float result );

/* Printout. c file */
# Include "printout. h"
Void pout (float result)
{
Printf ("the result is % f \ n", result );
}

/* Sq. h file */
Float squre (float f );

/* Sq. c file */
# Include "sq. h"
Float squre (float f)
{
Return f * f;
}

Put the above file in the same path, and then terminal (if there is no error running)

Gcc calc. c-c
Gcc printout. c-c
Gcc sq. c-c
Gcc calc. c printout. c sq. c-o calc (you can change other names here ).
./Calc is finished.
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.