ÓÃ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ÐÐ
Ïà¹ØÎĵµ£º
#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 ......
º¯ÊýÃû: stpcpy
¹¦ ÄÜ: ¿½±´Ò»¸ö×Ö·û´®µ½ÁíÒ»¸ö
ÓÃ ·¨: char *stpcpy(char *destin, char *source);
³ÌÐòÀý:
#include <stdio.h>
#include <string.h>
int main(void)
{
char string[10];
char *str1 = "abcdefghi";
stpcpy(string, str1);
& ......
ÕÒ´íÌâ
¡¡¡¡ÊÔÌâ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( ......
µ½ÁËmain.c£¬Æäʵmain.cÖеĴ󲿷ֵÄÄÚÈÝÊǵ÷Óú¯ÊýÀ´ÊµÏÖ³õʼ»¯µÄ¹¤×÷£¬µ«ÊÇ»¹Êǽ«Ëü¿´ÍêÁË¡£ÏÂÃæ¾ÍÊÇ´úÂëÁË¡£Ö÷Òª²Î¿¼µÄÊÇlinuxÄÚºËÍêȫעÊÍ£¬ÔÚһЩ²»Ì«Ã÷°×µÄµØ·½£¬²Î¿¼ÍøÉϵĽéÉÜ¡£·Ï»°ÉÙ˵¡£»¹Óкܳ¤µÄ·°¡¡£Å¬Á¦°¡O(∩_∩)O~¡£
/*
* main.c¹¦ÄÜÃèÊö¡£
*/
//main.c³ÌÐòµÄÖ÷Òª¹¦ÄÜÊÇÀûÓÃsetup.s ......
ͨ³£ÈËÃÇд³ÌÐòʱ¶¼Êǽ«ÎÄ×ÖдËÀÔÚ³ÌÐòÀïµÄ£¬±ÈÈ磺echo "Hello
World!";
£¬¼ÙÈçÒª¸Ä³ÉËü¹úÓïÑÔ£¬Ð´¹ú¼Ê»¯³ÌÐò£¬¾ÍÒªÖð¸ö´ò¿ª½øÐÐÐ޸쬳ÌÐò½Ï¶Ìʱ»¹ÐУ¬Èô³ÌÐòÓÐÉÏÍòÉõÖÁ¸ü¶à£¬¸ÄÆðÀ´¾Í²»ÊÇÄÇôÈÝÒ×ÁË¡£½üÀ´Ëæ×Åi18nµÄÖð½¥±ê
×¼»¯£¬ÎÒÒ²À´½²Ò»½²ÔÚPHPÖÐÈçºÎʵÏÖ¹ú¼Ê»¯Ö§³Ö¡£¸úÆäËû³ÌÐòÓïÑÔÒ»Ñù£¬ÔÚ PHP Ò²¿ ......