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

lua和c的交互


extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
 
#include <iostream>
#include <string>
using namespace std;
    
int main()
{
    //Lua示例代码
    char *szLua_code =
        "r = string.gsub(c_Str, c_Mode, c_Tag) --宿主给的变量 "
        "u = string.upper(r)";
    //Lua的字符串模式
    char *szMode = "(%w+)%s*=%s*(%w+)";
    //要处理的字符串
    char *szStr = "key1 = value1 key2 = value2";
    //目标字符串模式
    char *szTag = "<%1>%2</%1>";
 
    lua_State *L = luaL_newstate();
    luaL_openlibs(L);
 
    //把一个数据送给Lua
    lua_pushstring(L, szMode);
    lua_setglobal(L, "c_Mode");
    lua_pushstring(L, szTag);
    lua_setglobal(L, "c_Tag");
    lua_pushstring(L, szStr);
    lua_setglobal(L, "c_Str");
 
    //执行
    bool err = luaL_loadbuffer(L, szLua_code, strlen(szLua_code),
                "demo") || lua_pcall(L, 0, 0, 0);
    if(err)
    {
        //如果错误,显示
        cerr 


相关文档:

PHP调用C编程总结(windows)

一.环境的安装
   
    下载安装包,Google上搜索php+apache+sql的安装包并安装。
二.扩展编程
    针对在PHP环境下掉用C编程(c程序编译的dll),主要有以下两种方式。
   
    1.利用ATL构建DLL组件,然后再PHP里面直接调用,调用方法 ......

c/c++读写文件

#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
FILE *fp, *fp2;
char buf[1024*300];
fp = fopen("in.txt", "rb");
fp2 = fopen("out.txt", "wb+");
fseek(fp, 0, SEEK_END);
int iLen ......

C标准库


// 摘自:Wikipedia.org
C语言的标准文文件要求了一个平台移植C语言的时候至少要实现的一些功能和封装的集合,称为“标准库”,标准库的声明头部通过预处理器命令#include进行引用。
在C89标准中:
     01. <assert.h>
     02. <ctype.h>
&n ......

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


一.    首先做一个简单的so文件:
    /**
     * hello.c
     * To compile, use following commands:
     *   gcc -O -c -fPIC -o hello.o hello.c
     *   gcc -shared ......

求序列和的简单C程序

对于序列求和的程序大家不会陌生,而我今天看到的这个程序个人觉得比较好,所以贴上来共享一下。
要求:输入类似于87 98 67 56 0的任意序列,但是以零结尾。然后输出序列的和。
程序如下 :
/********************************************
 * Name : sum.c
 * Purpose : sum
 * Author : zimo
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号