易截截图软件、单文件、免安装、纯绿色、仅160KB

用php的c扩展编程调用 c程序的动态链接库


一.    首先做一个简单的so文件:
    /**
     * hello.c
     * To compile, use following commands:
     *   gcc -O -c -fPIC -o hello.o hello.c
     *   gcc -shared -o libhello.so hello.o
     */
    int hello_add(int a, int b)
    {
        return a + b;
    }
    然后将它编译成.so文件并放到系统中:
    $ gcc -O -c -fPIC -o hello.o hello.c
    $ gcc -shared -o libhello.so hello.o
    $ su
    # echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
    # cp libhello.so /usr/local/lib
    # /sbin/ldconfig
二.    写段小程序来验证其正确性:
    /**
     * hellotest.c
     * To compile, use following commands:
     *   gcc -o hellotest -lhello hellotest.c
     */
    #include <stdio.h>
    int main()
    {
        int a = 3, b = 4;
        printf("%d + %d = %d\n", a, b, hello_add(a,b));
        return 0;
    }
    编译并执行:
    $ gcc -o hellotest -lhello hellotest.c
    $ ./hellotest
    3 + 4 = 7
三.
    然后通过下面的命令建立一个名为 hello 的模块。
    $ ./ext_skel --extname=hello
    执行该命令之后它会提示你应当用什么命令来编译模块,可惜那是将模块集成到php内部的编译方法。如果要编译成可动态加载的 php_hello.so,方法要更为简单。
    $ cd hello
    首先编辑 config.m4 文件,去掉第16行和第18行


相关文档:

用C写的3D迷宫

          Boss说,要看OpenGL,看了快一个月,总算出了个像样的东西,用C写了个3D迷宫,
虽然只有350行
       代码,不过边学边写,足足写了一周时间,还是小有成就感的,活活活!
         &n ......

C 面试题之找错题


找错题
  试题1:
void test1()
{
 char string[10];
 char* str1 = "0123456789";
 strcpy( string, str1 );
}
  试题2:
void test2()
{
 char string[10], str1[10];
 int i;
 for(i=0; i<10; i++)
 {
  str1[i] = 'a';
 }
 strcpy( string, str1 );
}
  试题3:
void test3( ......

linux 下php的安装

    
环境软件版本介绍:
 
   APACHE 2.0.59
   PHP5.2.3
   MYSQL5.0.45
   GD-2.0.35
   Zend Optimizer v3.3.0
  
               &n ......

PHP 自定义函数实现系统函数功能


PHP 自定义函数实现系统函数功能
总是用别人写好的函数 是不是觉得不爽?好,下面跟着我来写吧~~以下代码全部由自己编写,绝无抄袭之嫌~~现贴上,仅供参考.(可能有些功能没有写全) 
说明一下,写系统函数再拿来使用确实很蠢,但只是作为练习,还有,在面试时确实是算法考得多,网上找来的面试题也大都要靠算法\语法熟练才能 ......

PHP循环语句

循环语句是 为了解决编程中 "需要重复一段指令直到满足特定条件为止" 的一种循环机制
1、while
     while语句指定了一个条件,在其嵌入代码结束执行前,必须满足这个条件。
     语法:
     while(expression){
      & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号