ʹÓÃCÓïÑÔÀ©Õ¹Python£¨Ò»£©
¿ª·¢»·¾³£ºUbuntu9.10,python2.6,gcc4.4.11,ubuntuϵÄpythonÔËÐаüºÍ¿ª·¢°üÊÇ·Ö¿ªµÄ£¬Òò´ËÐèÒªÔÚÐÂÀûµÃÀïÃæ°²×°python-all-dev,´Ó¶ø¿ÉÒÔÔÚ´úÂëÖÐÒýÓÃpythonµÄÍ·ÎļþºÍ¿â¡£2.ÏÂÃæÊÇÒ»¸ö×î¼òµ¥µÄ¿ÉÒÔ¹©pythonµ÷ÓõÄcÀ©Õ¹Ä£¿é£¬¼ÙÉèc³ÌÐòÎļþÃûΪfoo.c:´úÂë#include <Python.h>
static PyObject* foo_bar(PyObject* self, PyObject* args) {
Py_RETURN_NONE;
}
static PyMethodDef foo_methods[] = {
{"bar",(PyCFunction)foo_bar,METH_NOARGS,NULL},
{NULL,NULL,0,NULL}
};
PyMODINIT_FUNC initfoo() {
Py_InitModule3("foo", foo_methods, "My first extension module.");
} ÎÒÃÇ¿ÉÒÔ½«ÉÏÊöÄ£¿é·Ö³É3¸ö²¿·Ö£º1£©cÄ£¿éÏë¶ÔÍⱩ¶µÄ½Ó¿Úº¯Êý¡£2£©Ìṩ¸øÍⲿµÄpython³ÌÐòʹÓõÄÒ»¸öcÄ£¿éº¯ÊýÃû³ÆÓ³Éä±í¡£3£©cÄ£¿éµÄ³õʼ»¯º¯Êý¡£Ä£¿éµÄµÚÒ»Ðн«Python.hÒýÈ뵽ģ¿éÖУ¬Õâ¸öÎļþ½«Ê¹µÃÄãµÄÄ£¿é¿ÉÒÔhook½øpythonµÄ½âÊÍÆ÷£¬´Ó¶ø¿ÉÒÔΪÍⲿµÄpython³ÌÐòËùʹÓá£cÄ£¿éÖеĺ¯ÊýÇ©ÃûÒ»°ãÓÐÏÂÁÐÈýÖÖÐÎʽ£ºPyObject* MyFunction(PyObject* self, PyObject* args);
PyObject* MyFunctionWithKeywords(PyObject* self, PyObject* args, PyObject* kw);
PyObject* MyFunctionWithNoArgs(PyObject* self); Ò»°ãÎÒÃÇʹÓõÄÊǵÚÒ»ÖÖ·½Ê½£¬º¯ÊýµÄ²ÎÊý½«»áÒ»¸öÔª×é(tuple)µÄÐÎʽ´«½øÀ´£¬Òò´ËÎÒÃÇÔÚcÄ£¿éµÄº¯ÊýÖÐÐèÒª¶ÔÆä½øÐнâÎö¡£PythonÖв»ÄÜÏócÓïÑÔÒ»ÑùÉùÃ÷Ò»¸övoidÀàÐ͵ĺ¯Êý£¬Èç¹ûÄã²»Ï뺯Êý·µ»ØÒ»¸öÖµµÄ»°£¬ÄǾͷµ»ØÒ»¸öNONE,ÔÚÕâÀïÎÒÃÇ¿ÉÒÔͨ¹ýPythonÍ·ÎļþÖеÄÒ»¸öºêPy_RETURN_NONEÀ´ÊµÏÖ¡£CÄ£¿éÖеĺ¯ÊýÃû³ÆÆäʵ¶ÔÍⲿÀ´ËµÊDz»¿É¼ûµÄ£¬Òò´Ë¿ÉÒÔËæ±ãÄãÃüÃû£¬Ò»°ãÎÒÃÇ¿ÉÒÔʹÓÃstaticº¯Êý£¨ÕâÔÚCÓïÑÔÀï±íʾÔÚµ±Ç°ÎļþÒÔÍâÊDz»¿É¼ûµÄ£©¡£±¾Îĺ¯ÊýÃüÃû·½Ê½²ÉÓÃÄ£¿éÃû¼ÓÉϺ¯ÊýÃû£¬ÀýÈçfoo_bar,Õâ±íʾÔÚÄ£¿éfooÖлáÓÐÒ»¸öbarº¯Êý¡£È»ºó¾ÍÊǺ¯ÊýÓ³Éä±íÁË£¬ËüÊÇÒ»¸öPyMethodDef½á¹¹ÌåÊý×飬struct PyMethodDef {
char* ml_name;
PyCFunction ml_meth;
&nb
Ïà¹ØÎĵµ£º
#include <iostream>
using namespace std;
void main()
{
char *p,*q;
p = "abcde";
q = p + 3;
*q = 't';
cout<<p<<endl;
cout<<q<<endl;
}
Á½ÖÖÓïÑÔ±àÒ붼¿ÉÒÔͨ¹ý
µ±Ö´Ðе½
*q = 't';
ʱ£¬C++³ÌÐò³öÏÖÄÚ´æ·ÃÎÊ´íÎó£¬C³ÌÐò¿ÉÒ ......
×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½£¬ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
Ò»¼ÒÖ®ÑÔ£¬»¶ÓÅÄש¹þ¡£
1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC¡£
´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓÐÓõijÌÐòÔ±£¬×öÒ»¸ö׬ǮµÄ³ÌÐòÔ±¡£ÎÒÃǵļÛÖµ£¬½«ÌåÏÖÔÚ¿Í»§¼ÛÖµÉÏ£¬¶ø²» ......
C/SģʽºÍB/SģʽµÄÇø±ð
¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£
¡«¡«Ê²Ã´ÊÇB/Sģʽ
B/Sģʽ£¬¼´ä¯ÀÀÆ÷/·þÎñÆ÷ģʽ£¬ÊÇÒ»ÖÖ´Ó´«Í³µÄ¶þ²ãCSģʽ·¢Õ¹ÆðÀ´µÄеÄÍøÂç½á¹¹Ä£Ê½£¬Æä±¾ÖÊÊÇÈý²ã½á¹¹C/Sģʽ¡£B/SÍøÂç½á¹¹Ä£Ê½ÊÇ»ùÓÚIntr ......
C¡¢´«Í³ C++
#include <stdio.h>¡¡¡¡¡¡¡¡ //¶¨ÒåÊäÈ룯Êä³öº¯Êý
#include <stdlib.h>¡¡¡¡¡¡¡¡//¶¨ÒåÔÓÏÊý¼°ÄÚ´æ·ÖÅ亯Êý
#include <string.h>¡¡¡¡¡¡¡¡//×Ö·û´®´¦Àí
#include <assert.h>¡¡¡¡¡¡¡¡//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àí
#include <errno.h&g ......
ÒýÑÔ
×î½ü±ÊÕßÒ»Ö±ÔÚ×öJPEGµÄ½âÂ빤×÷£¬·¢ÏÖÓÃÍêȫʹÓùþ·òÂüÊ÷½øÐнâÂë±È½Ï·Ñʱ£¬¶øʹÓñí½á¹¹´æ´¢±àÂëºÍÖµµÄ¶ÔÓ¦¹Øϵ±È½Ï¿ì½Ý£¬µ«ÊÇÒ²´æÔڱȽÏÄÑ´¦ÀíµÄµØ·½£¬±ÈÈç½âÂ빤×÷ͨ³£ÊÇÒÔλΪµ¥Î»µÄ²Ù×÷£¬ÕâÀï±ØÈ»»áÉæ¼°µ½ÒÆλ²Ù×÷£¬¶ø±ÊÕß֮ǰ¶ÔλµÄ²Ù×÷ºÜÉÙ£¬¾ÑéºÜǷȱ£¬¾¹ýÕâ´ÎÀúÁ·ÖÕÓÚ·¢ÏÖÁËÒ»¸ö×Ô¼ºÔø¾ºöÊӵĶ«Î÷£¬ÄÇ¾Í ......