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

使用C语言扩展Python(三)

上一篇中我们已经了解如何在Python程序和C模块之间进行值的相互传递,现在我们来进入实作阶段,看看如何将一个C语言开发的开源mp3编解码库LAME包装为一个Python下可以使用的扩展模块。首先去http://lame.sourceforge.net/download.php下载LAME的源代码,然后切换到root用户编译源代码,./configure
make
make install安装完成后你可以在/usr/local/include/lame目录下找到lame.h头文件,我们在后面的demo程序中会include它的,下面就是一个非常简单的lame示例程序lame_test.c:代码#include <stdio.h>
#include <stdlib.h>
#include <lame.h>
#define INBUFSIZE 4096
#define MP3BUFSIZE (int) (1.25 * INBUFSIZE) + 7200
int encode(char* inPath, char* outPath) {
    int status = 0;
    lame_global_flags* gfp;
    int ret_code;
    FILE* infp;
    FILE* outfp;
    short* input_buffer;
    int input_samples;
    char* mp3_buffer;
    int mp3_bytes;
    
    gfp = lame_init();
    if (gfp == NULL) {
        printf("lame_init failed\n");
        status = -1;
        goto exit;
    }
    
    ret_code = lame_init_params(gfp);
    if (ret_code < 0) {
        printf("lame_init_params returned %d\n",ret_code);
        status = -1;
        goto close_lame;
    }


相关文档:

透析C/S和B/S两种模式的测试

C/S又称Client/Server或客户/服务器模式。服务器通常采用高性能的PC、工作站或小型机,并采用大型数据库系统,如Oracle、Sybase、Informix或 SQL Server。客户端需要安装专用的客户端软件。
  B/S是Brower/Server的缩写,客户机上只要安装一个浏览器(Browser),如Netscape Navigator或Internet Explorer,服务器安装O ......

[C代码]通讯录

/*****************test.c****************/
#include <stdio.h>
#include <stdlib.h>
#include "addr.h"
int main()
{
 int flag=1;
 while(flag)
 {
  switch(choose_menu())
  {
  case 1:add_person();break;
  case 2:show_person_in ......

symbian引用C标准库

symbian有自己的一套库。要好的成型的C代码,比如前两天为了解析XML我引用到的tinyxml。所以在symbian下引用C标准库就非常重要,这是对以前代码非常好的移植方式。
为了能用C标准库,主要修改mmp文件中的路径和库配置。添加如下两行,就可以用C标准库了。
SYSTEMINCLUDE  /epoc32/include/stdapis
LIBRARY  ......

C版《生日快乐》

#include<windows.h>

void Birthday();

int main()
{
Birthday();
return 0;
}

void Birthday()
{
unsigned frequency[]={392,392,440,392,523,494,

392,392,440,392,587,523,

......

c库函数详解——assert

c库函数详解——assert
函数名: assert
功  能: 测试一个条件并可能使程序终止
用  法: void assert(int test);
程序例:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct ITEM {
   int key;
   int value;
};
/* add item to ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号