C Language Study Notes: 14_internal and external functions

Source: Internet
Author: User
Tags define function

C Language Study Notes: 14_internal and external functions

/** 14 _ internal and external functions. c ** Created on: July 15, July 5, 2015 * Author: zhong */# include

 
  
# Include

  
   
/*** The so-called internal function is differentiated based on whether the function can be called by other sources. * 1: internal function: add a static function before Function Definition (this static function in C language is too far away from the static method in java) * If a function can only be called by other functions in this file, it is called an internal function, or a static function *. You only need to add a static keyword before the definition and function. In this case, you can restrict the scope of the function to this file. The effect is the same as that of the java private method. * For example, static int max (int a, int B) {} * not only limits the scope, but also allows you to define function names with the same name in different files in the same project, mutual interference ** 2: external functions: add an extern before the function definition. Of course, this extern keyword can be omitted, that is, the ordinary default function set at ordinary times * such: extern int fun (int a, int B) {}** when calling external functions of other files in this file, external function declaration is required (of course, the function prototype must be declared for calls in this file ). When declaring this function, add the keyword extern ***** // defines the internal function (static function) static int max _ (int a, int B) {return a> B? A: B;} // normal function (external function) extern int fun () {// extern can be omitted} int main () {extern void character_int_out_put (); // reference the "02 _ input/output function. c "file function, first declare it, Do not warn, but do not report character_int_out_put (); // call // system (pause); return 0 ;}

  

 

 

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.