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

Linux»·¾³MySQLµÄC±à³ÌÆð²½

Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢
°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
vim test.cpp
ÊäÈëÄÚÈÝ
#include
#include
#include "/usr/include/mysql/mysql.h"
int main() {
MYSQL mysql;
mysql_init(&mysql);
}
ctrl+O±£´æctrl+xÍ˳ö¡£
È»ºó±àÒë
g++ -lmysqlclient test.cpp -o test
ÔËÐÐ
./test
Èç¹ûʲô¶¼Ã»Ìáʾ£¬Ã»´íÎ󣬾Í˵Ã÷³É¹¦ÁË¡£
 
ÏÂÃæÊÇ×Ô¼ºÐ´µÄÒ»¸öС³ÌÐò£º²éѯmysql½øÐÐÈõµã¹ØÁª¡£
#include
#include
#include
#include
#include "/usr/include/mysql/mysql.h"
void asso_1(){
MYSQL mysql_conn; /* Mysql connection handle */
MYSQL_RES *mysql_result1, *mysql_result2, *mysql_result3; /* Result handle */
MYSQL_ROW mysql_row1, mysql_row2, mysql_row3; /* Row data */
int f1, f2, num_row1, num_col1, num_row2, num_col2;
printf("Start association analyse type 1: Weekness association\n");
int i;
for (i = 0; i<20; i++) printf("# ");
printf("\n");
if (mysql_init(&mysql_conn) == NULL) printf("Initialization fails\n");
if
(mysql_real_connect(&mysql_conn, "localhost", "root", "123456",
"test", 3306, NULL, 0) == NULL) printf("Connection fails\n");
if (mysql_query(&mysql_conn, "SELECT scid,aid,proto,dip,dport from `scan_table`") != 0)
printf("Query fails\n");
mysql_result1 = mysql_store_result(&mysql_conn);
num_row1 = mysql_num_rows(mysql_result1); /* Get the no. of row */
num_col1 = mysql_num_fields(mysql_result1); /* Get the no. of column */
for (f1 = 0; f1 < num_row1; f1++) {
mysql_row1 = mysql_fetch_row(mysql_result1); /* Get a row */
printf ("%s %s %s %s\n",mysql_row1[1],mysql_row1[2],mysql_row1[3],mysql_row1[4]);
char *str;
str = (char *)malloc(1024);
strcpy(s


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

ubuntu8.04.2ÏÂApache+Resin+Mysql°²×°+ÐéÄâÖ÷»úÅäÖÃ

 Ò» Apache°²×°
# tar zxvf httpd-2.2.14.tar.gz(½âѹ)
# cd httpd-2.2.14(½øÈë½âѹºóµÄĿ¼)
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all
  (ÃüÁî#./configure --help¿ÉÒԲ鿴configureµÄÅäÖòÎÊý
  --prefix=°²×°Â·¾¶
  --enable-so //´ò¿ª DSO Ö§³ÖµÄ a ......

MySQL²éѯÓÅ»¯¼¼ÊõϵÁн²×ù֮ʹÓÃË÷Òý£¨Ò»£©

 Ë÷ÒýÊÇÌá¸ß²éѯËٶȵÄ×îÖØÒªµÄ¹¤¾ß¡£µ±È»»¹ÓÐÆäËüµÄһЩ¼¼Êõ¿É¹©Ê¹Ó㬵«ÊÇÒ»°ãÀ´ËµÒýÆð×î´óÐÔÄܲîÒìµÄ¶¼ÊÇË÷ÒýµÄÕýȷʹÓá£ÔÚMySQLÓʼþÁбíÖУ¬ÈËÃÇ
¾­³£Ñ¯ÎÊÄÇЩÈòéѯÔËÐеøü¿ìµÄ·½·¨¡£ÔÚ´ó¶àÊýÇé¿öÏ£¬ÎÒÃÇÓ¦¸Ã»³ÒÉÊý¾Ý±íÉÏÓÐûÓÐË÷Òý£¬²¢ÇÒͨ³£ÔÚÌí¼ÓË÷ÒýÖ®ºóÁ¢¼´½â¾öÁËÎÊÌâ¡£µ±È»£¬²¢²»×ÜÊÇÕâÑù¼òµ¥
¾Í¿ÉÒÔ½ ......

C/C++±à³Ì¼¼ÄÜ¡¾ÕûÀí¡¿

Ô¤´¦ÀíÆ÷£¨Preprocessor£©
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³£Êý±í´ïʽµÄÖµ£¬Òò´Ë£¬Ö±½Ó ......

extern "C"

 ¡¡extern "C" °üº¬Ë«Öغ¬Ò壬´Ó×ÖÃæÉϼ´¿ÉµÃµ½£ºÊ×ÏÈ£¬±»ËüÐÞÊεÄÄ¿±êÊÇ“extern”µÄ£»Æä´Î£¬±»ËüÐÞÊεÄÄ¿±êÊÇ“C”µÄ¡£ÈÃÎÒÃÇÀ´Ïêϸ½â¶ÁÕâÁ½Öغ¬Òå¡£
¡¡¡¡£¨1£© ±»extern "C"ÏÞ¶¨µÄº¯Êý»ò±äÁ¿ÊÇexternÀàÐ͵ģ»
¡¡¡¡externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×Ö£¬¸Ã¹Ø¼ü× ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ