µÚÒ»¸öpro*C demo
¸Ã³ÌÐòºÜ¼òµ¥£¬¾ÍÊÇÓÃC´ÓORACLE£¬°Ñµ±Ç°ÈÕÆÚÏÔʾ³öÀ´¾ÍOK£¬×÷Ϊһ¸ö¼òµ¥µÄDEMO
£¨Ò»£©Ð´PRO*C
/*===========================================================================
* pro*c±àÒë·½·¨£º
* Ô¤±àÒë proc test.pc
* ±àÒë gcc -o test test.c $ORACLE_HOME/lib/libclntsh.so
* ×÷Õß foxliu
* ʱ¼ä 2009-10
*============================================================================*/
#include <stdio.h>
#include <sqlca.h>
int main(int argc,char **argv)
{
/*ÉùÃ÷SQL±äÁ¿*/
EXEC SQL BEGIN DECLARE SECTION;
/*VARCHARÔ¤±àÒëºóΪstruct { unsigned short len; unsigned char arr[20];}*/
VARCHAR user[20],pass[20],tnsname[20];
char crruentDate[15];
EXEC SQL END DECLARE SECTION;
/*ÉùÃ÷C±äÁ¿*/
int i=0;
strcpy(user.arr,"dbrevass");
user.len=strlen((char *)user.arr);
strcpy(pass.arr,"dbrevass");
pass.len=strlen((char *)pass.arr);
strcpy(tnsname.arr,"wapp");
tnsname.len=strlen((char *)tnsname.arr);
/*Connect the DB*/
EXEC SQL CONNECT :user IDENTIFIED BY :pass USING :tnsname;
/*printf("%d",sqlca.sqlcode);*/
/*ÓαêÉùÃ÷*/
EXEC SQL declare emp_cursor cursor for
select sysdate from dual;
&n
Ïà¹ØÎĵµ£º
ÍøÓѹ۵ã:
(Ò»):
ÎÒÈÏΪºÜ¶àÈËûÓÐÀí½âlinus»òÕßmyanµÄÒâ˼£¬ÎÒ¾Ù¸öʵÀý¡£
ÎÒÃÇÏÖÔÚÒªÉè¼ÆÒ»Ì×ÍøÂ磿ͻ§¶ËÈí¼þ£¬ÎÒÃÇÒªÏÈ°ÑÐÒ鶨ºÃ£¬°Ñ½çÃæºÍºǫ́½»»¥Éè¼ÆÏëºÃ£¬°ÑÈÝ´íºÍ»Ö¸´ÏëºÃ£¬ÎÒÈÏΪÕâЩÊÇ×îÖØÒªµÄ£¬ÖÁÓÚ±àÂ룬ÓÃCÒ²¿ÉÒÔ±à³öÀ´£¬ÓÃC£«£«Ò²¿ÉÒÔ±à³öÀ´£¬ÉõÖÁÓÃJAVAÒ²Äܱà³öÀ´£¬¹Ø¼üÊÇÕû¸öÈí¼þµÄ¼Ü¹¹ÒªÇåÎú£¬Õ ......
ÒÔÏÂÊÇÎҵIJâÊÔociµÄÀý×Ó£¡
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "oci.h"
static OCIServer *srvhp;
static OCISession *p_session;
static OCIEnv &nb ......
CÓïÑԵıê×¼¿âº¯Êý°üÀ¨Ò»ÏµÁÐÈÕÆÚºÍʱ¼ä´¦Àíº¯Êý£¬ËüÃǶ¼ÔÚÍ·ÎļþÖÐ˵Ã÷¡£ÏÂÃæÁгöÁËÕâЩº¯Êý¡£ÔÚÍ·ÎļþÖж¨ÒåÁËÈýÖÖÀàÐÍ£ºtime_t£¬struct tmºÍclock_t¡£
ÔÚÖÐ˵Ã÷µÄCÓïÑÔʱ¼äº¯Êý & ......
ÏÈÓñ´¶ûµÄÒ»µÀ±ÊÊÔÌâ¼òÒªµÄ˵Ã÷һϰɣº
¡¾Ì⡿˵Ã÷ÒÔϳÌÐò¡£
#include
int main(void)
{
unsigned int a[3] = {0x01020304, 0x05060708, 0x090a0b0c};
unsigned int *p = (unsigned int *)((int)a +1);¢Ù
printf("%x\n", *p);
return 0;
}
¡¾ÌâÄ¿½âÎö¡¿
Õâ¶Î³ÌÐòµÄÊä³ö½á¹ûÓ¦ ......
CÖеĿɱä²ÎÊýÑо¿
Ò»£® ºÎν¿É±ä²ÎÊý
int printf(const char* format, ...);
ÕâÊÇʹÓùýCÓïÑÔµÄÈËËùÔÙÊìϤ²»¹ýµÄprintfº¯ÊýÔÐÍ£¬ËüµÄ²ÎÊýÖоÍÓй̶¨²ÎÊýformat ......