Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

memcached Óëc/c++ÔËÓÃ

ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔ­À´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
    memcached_st *memc;
    uint32_t  flags;
    memcached_return rc;
    memcached_server_st *servers;
    memc= memcached_create(NULL);
    servers= memcached_servers_parse("127.0.0.1:12300");
    memcached_server_push(memc, servers);
    memcached_server_list_free(servers);
    memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 0);
   
Õâ¾ÍÊdzõʼ»¯µÄÈ«²¿´úÂ룬¿ÉÒÔÉèÖúܶණÎ÷£¬²»¹ýÎÒÏÖÔÚÖ»ÒªÒ»¸ö·þÎñÆ÷£¬¾Í¿´Ò»¾ä»°£º
    servers= memcached_servers_parse("127.0.0.1:12300");
Õâ¾ÍÊÇÖ¸Ã÷ÒªÁ¬½Óµ½Î»ÓÚ127.0.0.1¼àÌý12300¶Ë¿ÚµÄmemcached³ÌÐò. ÆäËû¶¼²»¹Ü¡£
×îºóÓÃÒ»¶ÎÐ޸ĺóµÄ´úÂë½éÉÜÁ½¸öº¯Êý£¬memcached_getºÍmemcached_set£¬¶¼¿ÉÒÔman³öÀ´¡£
        char * result_str; /*Õâ¸ö¾ÍÊDzéѯµÄ½á¹û*/
        std::string query="Òª²éѯµÄÊý¾ÝÃû";
        result_str= memcached_get(memc, query.c_str(), strlen(query.c_str()),
                &result_str_length, &flags, &rc);
        if (rc == MEMCACHED_SUCCESS)
        {
            printf("%s",result_str);
            free(result_str); /*Ò»¶¨Òªfreeµô memcached´«»ØµÄÊý¾Ý*/
            continue;
        }
        else if (rc == M


Ïà¹ØÎĵµ£º

C/C++ Í·Îļþ ³£ÓÃÍ·Îļþ¹¦Äܲéѯ±í

#include <assert.h>¡¡¡¡¡¡¡¡//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àí
#include <errno.h>¡¡¡¡¡¡¡¡ //¶¨Òå´íÎóÂë
#include <float.h>¡¡¡¡¡¡¡¡ //¸¡µãÊý´¦Àí
#include <fstream.h>¡¡¡¡¡¡ //ÎļþÊäÈ룯Êä³ö
#include  ......

extern cµÄ×÷ÓÃ

extern cµÄ×÷Óá¾×ª¡¿
2009-12-18 13:10
1.ÒýÑÔ
C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³Ì ʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓ ......

extern "C"

CºÍC++»¥Ïàµ÷Óú¯Êýʱ£¬Ê¹ÓÃextern "C"¡£
Ô­Òò£º
C²»Ö§³Öº¯ÊýÖØÔØ£¬¶øC++Ö§³Öº¯ÊýÖØÔØ¡£º¯Êý±»C++±àÒëºó»áÃû×ÖÓëCÓïÑÔ²»Í¬¡£¼ÙÉèijº¯ÊýÔ­ÐÍΪfoo(ing x, int y)£¬±»C++±àÒëºóÃû×ÖΪ_foo_int_int£¬¶øC±àÒëÆ÷±àÒëºóÃû×ÖΪ_foo¡£ ......

¹¹½¨»ù±¾µÄLinux C ±à³Ì»·¾³ £¨×ªµÄÔõôÊղز»ÁË£©

  ¹¹½¨»ù±¾µÄLinux C ±à³Ì»·¾³ ÊÕ²Ø
±¾ÎÄ»ùÓÚdebian-40r0(ÄÚºË2.6.18)½éÉÜÒ»ÏÂÈçºÎÔÚÒ»¸ö±ê׼ϵͳÖй¹½¨Linux CµÄ»ù±¾±à³Ì¿ª·¢»·¾³¡£
Ò»¸öÍêÕûµÄ¿ª·¢»·¾³Ö÷Òª°üÀ¨Ëĸö²¿·Ö£º±ê×¼C¿â¡¢Í·Îļþ¡¢¹¤¾ßÁ´¡¢±à¼­Æ÷¡¢°ïÖúÎĵµ£¬ÏÂÃæÒÀ´Î½éÉÜ¡£
±ê×¼C¿âglibc
glibcÊÇgnu·¢²¼µÄlibc¿â£¬¼´cÔËÐп⡣glibcÊÇlinuxϵͳÖÐÄÚºËÖ ......

C/C++ÃæÊÔÌâÁù£¨¾­µä) ¡¾×ª¡¿

1.ÇóÏÂÃ溯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
int func(x)
{
    int countx = 0;
    while(x)
    {
          countx ++;
          x = x&(x-1);
     } ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ