Source code:

   1: #include<stdio.h>

   2: void myStartupFun (void) __attribute__ ((constructor));

   3: void myCleanupFun (void) __attribute__ ((destructor));

   4:   

   5: /* implementation of myStartupFun */

   6: void myStartupFun (void)

   7: {

   8:     printf ("startup code before main()\n");

   9: }

  10:  

  11: /* implementation of myCleanupFun */

  12: void myCleanupFun (void)

  13: {

  14:     printf ("cleanup code after main()\n");

  15: }

  16:  

  17: int main (void)

  18: {

  19:     printf ("hello\n");

  20:     return 0;

  21: }

 

Just compile the source code, and run, you will find the interesting result.

Insert Function before and after main function的更多相关文章

  1. [Cycle.js] Customizing effects from the main function

    How can we show one string on the DOM, and a completely different string on Console log? This lesson ...

  2. [Cycle.js] Main function and effects functions

    We need to give structure to our application with logic and effects. This lessons shows how we can o ...

  3. Main function

    Main function A program shall contain a global function named main, which is the designated start of ...

  4. The App Life Cycle & The Main Function

    The App Life Cycle Apps are a sophisticated interplay between your custom code and the system framew ...

  5. SetApartmentState(ApartmentState state).Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process

    System.Threading.ThreadStateException: 'Current thread must be set to single thread apartment (STA) ...

  6. Adding New Functions to MySQL(User-Defined Function Interface UDF、Native Function)

    catalog . How to Add New Functions to MySQL . Features of the User-Defined Function Interface . User ...

  7. 在JS中关于堆与栈的认识function abc(a){ a=100; } function abc2(arr){ arr[0]=0; }

    平常我们的印象中堆与栈就是两种数据结构,栈就是先进后出:堆就是先进先出.下面我就常见的例子做分析: main.cpp int a = 0; 全局初始化区 char *p1; 全局未初始化区 main( ...

  8. 洛谷P1464 Function  HDU P1579 Function Run Fun

    洛谷P1464 Function HDU P1579 Function Run Fun 题目描述 对于一个递归函数w(a,b,c) 如果a≤0 or b≤0 or c≤0就返回值11. 如果a> ...

  9. JavaScript中函数function fun(){}和 var fun=function(){}的区别

    function fun(){} 和 var fun=function(){}的区别 标题有点长···· 废话少说,其实他们的主要区别就是"函数声明的提前行为". var fun= ...

随机推荐

  1. Coursera台大机器学习技法课程笔记04-Soft-Margin Support Vector Machine

    之前的SVM非常的hard,要求每个点都要被正确的划分,这就有可能overfit,为此引入了Soft SVM,即允许存在被错分的点,将犯的错放在目 标函数中进行优化,非常类似于正则化. 将Soft S ...

  2. linux文件分割(将大的日志文件分割成小的)

    linux文件分割(将大的日志文件分割成小的) linux下文件分割可以通过split命令来实现,可以指定按行数分割和安大小分割两种模式.Linux下文件合并可以通过cat命令来实现,非常简单. 在L ...

  3. Bulb Switcher

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  4. JSON: property "xxx" has no getter method in class "..."

    Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Pro ...

  5. codeforces B. Vasya and Public Transport 解题报告

    题目链接:http://codeforces.com/problemset/problem/355/B 题目意思:给出四种票种,c1: 某一部bus或者trolley的单程票(暗含只可以乘坐一次):c ...

  6. 《Algorithms算法》笔记:优先队列(2)——二叉堆

    二叉堆 1 二叉堆的定义 堆是一个完全二叉树结构(除了最底下一层,其他层全是完全平衡的),如果每个结点都大于它的两个孩子,那么这个堆是有序的. 二叉堆是一组能够用堆有序的完全二叉树排序的元素,并在数组 ...

  7. eclipse 向HDFS中创建文件夹报错 permission denied

    环境:win7  eclipse    hadoop 1.1.2 当执行创建文件的的时候, 即: String Path = "hdfs://host2:9000"; FileSy ...

  8. 关于struts 2中的日期问题

    struts 2中引入了大量的jquery的内容 其中日期问题总结一下: 步骤: 1.当然不用说,先建一个web项目 2.导入struts2所需要的jar包,以及此插件的包(当然你也可以用:strut ...

  9. 以多个实例方式打开Notepad++

    Right-click any Notepad++ shortcut. Select Properties. Move to the Shortcut tab. In the end of the T ...

  10. Maven打包部署脚本

    #!/bin/sh SVN_USER_NAME= SVN_PASSWORD= ROOT_PATH PROJECT_NAME ACTION SVN_LIB_ROOT USER_ACCOUNT PASSW ...