Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : c

»ñÈ¡IPµÄC ´úÂë

»ñÈ¡IPµÄC ´úÂë #include<stdio.h> #include<winsock2.h> #pragma comment(lib,"ws2_32.lib") void CheckIP(void) //¶¨ÒåCheckIP£¨£©º¯Êý£¬ÓÃÓÚ»ñÈ¡±¾»úIPµØÖ· { WSADATA wsaData; char name[255]; //¶¨ÒåÓà ...
»ñÈ¡IPµÄC ´úÂë
#include<stdio.h>
#include<winsock2.h>
#pragma comment(lib,"ws2_32.lib")
void CheckIP(void) //¶¨ÒåCheckIP£¨£©º¯Êý£¬ÓÃÓÚ»ñÈ¡±¾»úIPµØÖ·
{
WSADATA wsaData;
char name[255]; //¶¨ÒåÓÃÓÚ´æ·Å»ñµÃµÄÖ÷»úÃûµÄ±äÁ¿
char *ip; //¶¨ÒåIPµØÖ·±äÁ¿
PHOSTENT hostinfo;
//µ÷ÓÃMAKEWORD£¨£©»ñµÃWinsock°æ±¾µÄÕýÈ·Öµ£¬ÓÃÓÚ¼ÓÔØWinsock¿â
if ( WSAStartup( MAKEWORD(2,0), &wsaData ) == 0 ) {
//ÏÖÔÚÊǼÓÔØWinsock¿â£¬Èç¹ûWSAStartup£¨£©º¯Êý·µ»ØֵΪ0£¬ËµÃ÷¼ÓÔسɹ¦£¬³ÌÐò¿ÉÒÔ¼ÌÐø
if( gethostname ( name, sizeof(name)) == 0) {
//Èç¹û³É¹¦µØ½«±¾µØÖ÷»úÃû´æ·ÅÈëÓÉname²ÎÊýÖ¸¶¨µÄ»º³åÇøÖÐ
if((hostinfo = gethostbyname(name)) != NULL) {
//ÕâÊÇ»ñÈ¡Ö÷»úÃû£¬Èç¹û»ñµÃÖ÷»úÃû³É¹¦µÄ»°£¬½«·µ»ØÒ»¸öÖ¸Õ룬ָÏòhostinfo£¬hostinfo
//ΪPHOSTENTÐ͵ıäÁ¿£¬ÏÂÃæ¼´½«Óõ½Õâ¸ö½á¹¹Ìå
ip = ......

c/c++ÖеÄconst¹Ø¼ü×Ö

const£¬c\c++Öзdz£³£ÓõĹؼü×Ö¡£
Ê×ÏÈÎÒÃÇ¿´¿´constÓÐÄÇЩÐÞÊη½·¨¡£
×îÇ°ÃæÎÒÃÇÀ´¿´Ò»¸öÎÊÌâ¡£
char *p = "123";
¿ÉÄÜÓеÄÈ˲»ÖªµÀ£¬ÕâÀïµÄÕâ¸ö"123"ÊÇ´æ´¢ÔÚ³£Á¿ÇøµÄ£¬²»ÈÝÐíÐ޸ĵġ£
Ò²¾ÍÊÇ˵ËüÊǸöconstÀàÐ͵ġ£
±ê×¼µÄд·¨Ó¦¸ÃÊÇ
char const *p = "123";
ÖÁÓÚΪʲô±àÒëÆ÷ÈÝÐíÉÏÃæµÄÄǸö²»±ê×¼µÄд·¨£¬¿ÉÄÜÊÇÒòΪ¼æÈÝÐÔµÄÎÊÌâ°É¡£
char p[4] = "123";//Õâ¸öºÍÉÏÃæµÄ¿ªÊ¼´ó²»Ò»ÑùµÄ°¡¡£
ÇÐÈëÕýÌâ¡£
const int s = 0;
ÉÏÃæµÄºÜÈÝÒ×Àí½â¡£µ«´øÉÏÖ¸ÕëÓÐЩͬѧ¿ÉÄܾÍÒª»èÁË¡£
const int *p = &s;//£¨1£©
int const *p = &s;//£¨2£©
int * const p = &s;//£¨3£©
const int * const p = &s;//£¨4£©
£¨1£©ºÍ£¨2£©µÄЧ¹ûÊÇÒ»ÑùµÄ£¬Òâ˼ÊÇ p ÊǿɱäµÄ£¬µ«ÊÇ p Ö¸ÏòµÄÖµÊDz»¿É±äµÄ¡£
£¨3£©¾Í¸ÕºÃÏà·´£¬p ÊDz»¿É±äµÄ£¬Ö»ÄÜÖ¸ÏòÒ»¸öµØ·½£¬µ«ÊÇ p Ö¸ÏòµÄÖµÊǿɱäµÄ¡£
£¨4£©p²»¿É±ä£¬*p Ò²²»¿É±ä¡£
ÎÒÃǾٸöÀý×Ó¿´¿´¡£
int s = 0;
const int *p = &s;
p++;//¿ÉÒÔ
p--;//¿ÉÒÔ
*p = 4;//´íÎó
------------------------------
int s = 0;
int * const p = &s;
*p = 4;//¿ÉÒÔ
p++;//´íÎó
------------------------------
ÓеÄÊ ......

c/c++ÖеÄconst¹Ø¼ü×Ö

const£¬c\c++Öзdz£³£ÓõĹؼü×Ö¡£
Ê×ÏÈÎÒÃÇ¿´¿´constÓÐÄÇЩÐÞÊη½·¨¡£
×îÇ°ÃæÎÒÃÇÀ´¿´Ò»¸öÎÊÌâ¡£
char *p = "123";
¿ÉÄÜÓеÄÈ˲»ÖªµÀ£¬ÕâÀïµÄÕâ¸ö"123"ÊÇ´æ´¢ÔÚ³£Á¿ÇøµÄ£¬²»ÈÝÐíÐ޸ĵġ£
Ò²¾ÍÊÇ˵ËüÊǸöconstÀàÐ͵ġ£
±ê×¼µÄд·¨Ó¦¸ÃÊÇ
char const *p = "123";
ÖÁÓÚΪʲô±àÒëÆ÷ÈÝÐíÉÏÃæµÄÄǸö²»±ê×¼µÄд·¨£¬¿ÉÄÜÊÇÒòΪ¼æÈÝÐÔµÄÎÊÌâ°É¡£
char p[4] = "123";//Õâ¸öºÍÉÏÃæµÄ¿ªÊ¼´ó²»Ò»ÑùµÄ°¡¡£
ÇÐÈëÕýÌâ¡£
const int s = 0;
ÉÏÃæµÄºÜÈÝÒ×Àí½â¡£µ«´øÉÏÖ¸ÕëÓÐЩͬѧ¿ÉÄܾÍÒª»èÁË¡£
const int *p = &s;//£¨1£©
int const *p = &s;//£¨2£©
int * const p = &s;//£¨3£©
const int * const p = &s;//£¨4£©
£¨1£©ºÍ£¨2£©µÄЧ¹ûÊÇÒ»ÑùµÄ£¬Òâ˼ÊÇ p ÊǿɱäµÄ£¬µ«ÊÇ p Ö¸ÏòµÄÖµÊDz»¿É±äµÄ¡£
£¨3£©¾Í¸ÕºÃÏà·´£¬p ÊDz»¿É±äµÄ£¬Ö»ÄÜÖ¸ÏòÒ»¸öµØ·½£¬µ«ÊÇ p Ö¸ÏòµÄÖµÊǿɱäµÄ¡£
£¨4£©p²»¿É±ä£¬*p Ò²²»¿É±ä¡£
ÎÒÃǾٸöÀý×Ó¿´¿´¡£
int s = 0;
const int *p = &s;
p++;//¿ÉÒÔ
p--;//¿ÉÒÔ
*p = 4;//´íÎó
------------------------------
int s = 0;
int * const p = &s;
*p = 4;//¿ÉÒÔ
p++;//´íÎó
------------------------------
ÓеÄÊ ......

cÏÝÚåÓëȱÏÝѧϰ±Ê¼Ç

http://c.chinaitlab.com/c/basic/200907/789321.html
  ´Ê·¨ÏÝÚ壺
    1        = ²»Í¬ÓÚ£½£½²»ÒªÔÚ³ÌÐòÖн«Á½Õßд´í£¬Ð¡ÐÄ¡£½«±í´ïʽÓë³£Á¿±È½Ïʱ£¬¿É½«³£Á¿·ÅÔÚ×ó±ß¡£
    2        &ºÍ| ²»Í¬ÓÚ&& ºÍ ||.
    3        ´Ê·¨·ÖÎöÖеÄÌ°ÐÄ·¨£ºÃ¿¸ö·ûºÅÓ¦¸Ã°üº¬¾¡¿ÉÄܶàµÄ×Ö·û¡£Èç¹û£¨±àÒëÆ÷µÄ£©ÊäÈëÁ÷½ØÖÁij¸ö×Ö·ûÇ°¶¼ÒѾ­·Ö½âΪһ¸ö¸ö·ûºÅ£¬ÄÇôÏÂÒ»¸ö·ûºÅ½«°üÀ¨´Ó¸Ã×Ö·ûÖ®ºó¿ÉÄÜ×é³ÉÒ»¸ö×Ö·ûµÄ××Ö·û´®¡£Èçy = x/*p£¬ÄÇô/*½«×÷Ϊһ¸ö·ûºÅ¶Ô´ý¡£
    4        Èç¹ûÒ»¸öÕûÐαäÁ¿µÚÒ»¸ö×Ö·ûÊÇ0£¬ÄÇô¸Ã³£Á¿±»ÊÓΪ8½øÖÆÊý¡£
    5        Char c = ‘cxf’¡£ÔÚvcºÍGccÖУ¬ÒÀ´ÎÓúóÒ»¸ö×Ö·û¸²¸ÇÇ°Ò»¸ö×Ö·û£¬×îºóµÃµ½µÄÕûÊýÖµÊÇ×îºóÒ»¸ö×Ö·ûµÄÕûÊýÖµ¡£
    Óï·¨ÏÝÚ壺
    1       
c±äÁ¿ÉùÃ÷ÓÉÀàÐ ......

cÖÐÄÚ´æ·Ö²¼

¶ÑºÍÕ»µÄÇø±ð
Ò»¡¢Ô¤±¸ÖªÊ¶—³ÌÐòµÄÄÚ´æ·ÖÅä
Ò»¸öÓÉc/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£©— Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬ Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅ䷽ʽµ¹ÊÇÀàËÆÓÚÁ´±í£¬ºÇºÇ¡£
3¡¢È«¾ÖÇø£¨¾²Ì¬Çø£©£¨static£©—£¬È«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬ δ³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£ - ³ÌÐò½áÊøºóÓÐϵͳÊÍ·Å
4¡¢ÎÄ×Ö³£Á¿Çø—³£Á¿×Ö·û´®¾ÍÊÇ·ÅÔÚÕâÀïµÄ¡£ ³ÌÐò½áÊøºóÓÉϵͳÊÍ·Å
5¡¢³ÌÐò´úÂëÇø—´æ·Åº¯ÊýÌåµÄ¶þ½øÖÆ´úÂë¡£
¶þ¡¢Àý×Ó³ÌÐò
ÕâÊÇÒ»¸öÇ°±²Ð´µÄ£¬·Ç³£Ïêϸ
//main.cpp
int a = 0; È«¾Ö³õʼ»¯Çø
char *p1; È«¾Öδ³õʼ»¯Çø
main()
{
int b; Õ»
char s[] = "abc"; Õ» ("abc"ÔÚÕ»ÖУ¬sÒ²ÊÇÕ»ÖеØÖ·³£Á¿£¬*s¼´Îªa£©
char *p2; Õ»
char *p3 = "123456"; 123456\0ÔÚ³£Á¿Çø£¬p3ÔÚÕ»ÉÏ¡£
static int c =0£» È«¾Ö£¨¾²Ì¬£©³õʼ»¯Çø
p1 = (char *)m ......

Pro*C Á¬½ÓÊý¾Ý¿âʱdbname µÄÉèÖÃ

    ×î½üÒ»¶Îʱ¼äÔÚÑо¿ Pro*C Óöµ½Á˺ܶà³õ¼¶ÎÊÌâ¡£ÔÚ Pro*C ÖÐÁ¬½ÓÊý¾Ý¿âʱ£¬ÎÒÃÇÒ»°ãÊÇʹÓÃÔÚ“tnsnames.ora”ÖÐÅäÖúÃÁ¬½Ó£¬Ð´ÆðÀ´ºÜ¼òµ¥£¬Óï·¨ÈçÏ£º
    EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname;
    /* ÕâÀïµÄ dbname ¾ÍÊÇÔÚ“tnsnames.ora” ÅäÖúõÄÃû³Æ */
    ÄÇôÈç¹ûûÓÐÔÚ“tnsnames.ora”ÖÐÅäÖÃÏàÓ¦µÄÁ¬½ÓÐÅÏ¢£¬ÒªÈçºÎд dbname ÄØ£¿ÎÒÔÚÍøÉÏÕÒÁ˺ÃÒ»Õó¶¼Ã»ÕÒµ½ºÏÊʵĴ𰸣¬Ö»ÄÜ×Ô¼ºÊÔÁË¡£ÊÔÁ˼¸´ÎÖÕÓڵõ½Á˴𰸣¬Æäʵ dbname ÉèÖÃÓдËÀàËÆȥдJDBCÖеÄÁ¬½Ó×Ö·û´®£¬¼´£º“IPµØÖ·:¶Ë¿ÚºÅ/ʵÀýÃû” ÀýÈ磺Á¬½Ó±¾µØµÄ Oracle Express ¾Í¿ÉÒÔд³É“localhost:1521/XE”¡£ ......

ÈçºÎÀí½âcºÍc++µÄ¸´ÔÓÀàÐÍÉùÃ÷

 Ôø¾­Åöµ½¹ýÈÃÄãÃԻ󲻽⡢ÀàËÆÓÚint * (* (*fp1) (int) ) [10];ÕâÑùµÄ±äÁ¿ÉùÃ÷Âð£¿
±¾ÎĽ«ÓÉÒ×µ½ÄÑ£¬Ò»²½Ò»²½½Ì»áÄãÈçºÎÀí½âÕâÖÖ¸´ÔÓµÄC/C++ÉùÃ÷¡£
ÎÒÃǽ«´ÓÿÌ춼ÄÜÅöµ½µÄ½Ï¼òµ¥µÄÉùÃ÷ÈëÊÖ£¬È»ºóÖð²½¼ÓÈëconstÐÞÊηûºÍtypedef£¬»¹Óк¯ÊýÖ¸Õ룬×îºó½éÉÜÒ»¸öÄܹ»ÈÃÄã׼ȷµØÀí½âÈκÎC/C++ÉùÃ÷µÄ“ÓÒ×ó·¨Ôò”¡£
ÐèҪǿµ÷һϵÄÊÇ£¬¸´ÔÓµÄC/C++ÉùÃ÷²¢²»ÊǺõıà³Ì·ç¸ñ£»ÎÒÕâÀï½ö½öÊǽÌÄãÈçºÎÈ¥Àí½âÕâЩÉùÃ÷¡£×¢Ò⣺ΪÁ˱£Ö¤Äܹ»ÔÚͬһÐÐÉÏÏÔʾ´úÂëºÍÏà¹Ø×¢ÊÍ£¬±¾ÎÄ×îºÃÔÚÖÁÉÙ1024x768·Ö±æÂʵÄÏÔʾÆ÷ÉÏÔĶÁ¡£
ÈÃÎÒÃÇ´ÓÒ»¸ö·Ç³£¼òµ¥µÄÀý×Ó¿ªÊ¼£¬ÈçÏ£º
int n;
Õâ¸öÓ¦¸Ã±»Àí½âΪ“declare n as an int”£¨nÊÇÒ»¸öintÐ͵ıäÁ¿£©¡£½ÓÏÂÈ¥À´¿´Ò»ÏÂÖ¸Õë±äÁ¿£¬ÈçÏ£º
int *p;
Õâ¸öÓ¦¸Ã±»Àí½âΪ“declare p as an int *”£¨pÊÇÒ»¸öint *Ð͵ıäÁ¿£©£¬»òÕß˵pÊÇÒ»¸öÖ¸ÏòÒ»¸öintÐͱäÁ¿µÄÖ¸Õë¡£ÎÒÏëÔÚÕâÀïÕ¹¿ªÌÖÂÛһϣºÎÒ¾õµÃÔÚÉùÃ÷Ò»¸öÖ¸Õ루»òÒýÓã©ÀàÐ͵ıäÁ¿Ê±£¬×îºÃ½«*£¨»ò&£©Ð´ÔÚ½ô¿¿±äÁ¿Ö®Ç°£¬¶ø²»Êǽô¸ú»ù±¾ÀàÐÍÖ®ºó¡£ÕâÑù¿ÉÒÔ±ÜÃâһЩÀí½âÉϵÄÎóÇø£¬±ÈÈ磺
ÔÙÀ´¿´Ò»¸öÖ¸ÕëµÄÖ¸ÕëµÄÀý×Ó£º
char **argv;
ÀíÂÛÉÏ£¬¶ÔÓÚÖ¸ÕëµÄ¼¶ÊýÃ»Ó ......

ÈçºÎÀí½âcºÍc++µÄ¸´ÔÓÀàÐÍÉùÃ÷

 Ôø¾­Åöµ½¹ýÈÃÄãÃԻ󲻽⡢ÀàËÆÓÚint * (* (*fp1) (int) ) [10];ÕâÑùµÄ±äÁ¿ÉùÃ÷Âð£¿
±¾ÎĽ«ÓÉÒ×µ½ÄÑ£¬Ò»²½Ò»²½½Ì»áÄãÈçºÎÀí½âÕâÖÖ¸´ÔÓµÄC/C++ÉùÃ÷¡£
ÎÒÃǽ«´ÓÿÌ춼ÄÜÅöµ½µÄ½Ï¼òµ¥µÄÉùÃ÷ÈëÊÖ£¬È»ºóÖð²½¼ÓÈëconstÐÞÊηûºÍtypedef£¬»¹Óк¯ÊýÖ¸Õ룬×îºó½éÉÜÒ»¸öÄܹ»ÈÃÄã׼ȷµØÀí½âÈκÎC/C++ÉùÃ÷µÄ“ÓÒ×ó·¨Ôò”¡£
ÐèҪǿµ÷һϵÄÊÇ£¬¸´ÔÓµÄC/C++ÉùÃ÷²¢²»ÊǺõıà³Ì·ç¸ñ£»ÎÒÕâÀï½ö½öÊǽÌÄãÈçºÎÈ¥Àí½âÕâЩÉùÃ÷¡£×¢Ò⣺ΪÁ˱£Ö¤Äܹ»ÔÚͬһÐÐÉÏÏÔʾ´úÂëºÍÏà¹Ø×¢ÊÍ£¬±¾ÎÄ×îºÃÔÚÖÁÉÙ1024x768·Ö±æÂʵÄÏÔʾÆ÷ÉÏÔĶÁ¡£
ÈÃÎÒÃÇ´ÓÒ»¸ö·Ç³£¼òµ¥µÄÀý×Ó¿ªÊ¼£¬ÈçÏ£º
int n;
Õâ¸öÓ¦¸Ã±»Àí½âΪ“declare n as an int”£¨nÊÇÒ»¸öintÐ͵ıäÁ¿£©¡£½ÓÏÂÈ¥À´¿´Ò»ÏÂÖ¸Õë±äÁ¿£¬ÈçÏ£º
int *p;
Õâ¸öÓ¦¸Ã±»Àí½âΪ“declare p as an int *”£¨pÊÇÒ»¸öint *Ð͵ıäÁ¿£©£¬»òÕß˵pÊÇÒ»¸öÖ¸ÏòÒ»¸öintÐͱäÁ¿µÄÖ¸Õë¡£ÎÒÏëÔÚÕâÀïÕ¹¿ªÌÖÂÛһϣºÎÒ¾õµÃÔÚÉùÃ÷Ò»¸öÖ¸Õ루»òÒýÓã©ÀàÐ͵ıäÁ¿Ê±£¬×îºÃ½«*£¨»ò&£©Ð´ÔÚ½ô¿¿±äÁ¿Ö®Ç°£¬¶ø²»Êǽô¸ú»ù±¾ÀàÐÍÖ®ºó¡£ÕâÑù¿ÉÒÔ±ÜÃâһЩÀí½âÉϵÄÎóÇø£¬±ÈÈ磺
ÔÙÀ´¿´Ò»¸öÖ¸ÕëµÄÖ¸ÕëµÄÀý×Ó£º
char **argv;
ÀíÂÛÉÏ£¬¶ÔÓÚÖ¸ÕëµÄ¼¶ÊýÃ»Ó ......
×ܼǼÊý:2015; ×ÜÒ³Êý:336; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [326] [327] [328] [329] 330 [331] [332] [333] [334] [335]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ