½âÎöCÓëC++ÖеĹؼü×Öconst
ÔÚCÓëC++ÓïÑÔÖж¼´æÔڹؼü×Öconst,ºÜ¶àÈ˶¼¶Ô´Ë¹Ø¼ü×Ö´æÔÚÒ»¸ö´íÎóµÄÈÏʶ£¬ÈÏΪÔÚCÓïÑÔÖйؼü×ÖconstÊÇʹ±äÁ¿×÷Ϊһ¸ö³£Á¿£¬¼´½«±äÁ¿³£Á¿»¯£¬¾ÍÏñºê¶¨ÒåÒ»Ñù¡£¶øÔÚCÓïÑÔÖеĹؼü×ÖconstËùÆðµÄ×÷Óò¢²»ÊÇʹ±äÁ¿³£Á¿»°£¬¶øÊÇÏÞÖƱäÁ¿£¬Ê¹±äÁ¿³ýÁ˱»¸³³õÖµÍ⣬ÎÞ·¨±»ÖØи³Öµ¡£
¶øÔÚC++Öйؼü×Öconst²»½öʹ¸Ã±äÁ¿ÎÞ·¨Ð޸ģ¬Ò²ÊÇʹ±äÁ¿³£Á¿»¯£¬¼´½«±äÁ¿¸³³õÖµºó¿ÉÒÔµ±×÷³£Á¿Ê¹Óã¬Ï൱ÓÚ½øÐÐÁ˺궨Òå¡£
ÔÚ±àÒëÆ÷ÖÐÊäÈëÒÔÏ´úÂ룬Äã»áÓиüÖ±¹ÛµÄÌå»á¡£
ÔÚCÓïÑÔ±àÒëÆ÷ÖУº
/* constÏÞÖƵıäÁ¿µÄÖµÎÞ·¨ÐÞ¸Ä*/
#include <stdio.h>
int main(void)
{
const int a=1;
int const b=1;
a=1;
b=1;
system("pause");
return 0;
}
µ±Ä㽫Õâ¶Î´úÂë±àÒëʱ£¬±àÒëÆ÷»á±¨´í£ºÔÚmianº¯ÊýÖÐÎÞ·¨ÐÞ¸ÄconstÏÞÖƵĶÔÏó¡£
×¢£ºÔÚCÓïÑÔÖУ¬¹Ø¼ü×Öconst±»·ÅÔÚ±êʶ·û֮ǰ»òÖ®ºóÊÇÒ»ÑùµÄЧ¹û¡£
/* constÏÞÖƵıäÁ¿ÎÞ·¨ÐÞ¸Ä*/
#include <stdio.h>
int main(void)
{
const int a=1;
switch(1)
{
case a:prinf("variable a can be used as constant");break;
default :printf("variable a cannot be used as constant");
}
system("pause");
return 0;
}
µ±Äã±àÒëÕâ¶Î´úÂëÊÇ£¬±àÒëÆ÷»á±¨´í£ºÔÚmainº¯ÊýÖÐÒªÇóʹÓó£Á¿¡£
¹Ø¼ü×Öconst¶ÔÖ¸ÕëµÄÏÞÖÆ£º
/*cosntÔÚ*Ç°£¬Ö¸ÕëÖ¸Ïò¶ÔÏóµÄÖµÎÞ·¨ÐÞ¸Ä*/
#include <stdio.h>
int main(void)
{
int a=1,b=2;
const int * p1=&a;
int const * p2=&b;
*p1=1;
*p2=1;
system("pause");
return 0;
}
constÔÚÐǺÅÇ°¶Ô¶ÔÖ¸Õë±äÁ¿½øÐÐÏÞÖÆʱÊǶÔÖ¸Õë±äÁ¿ËùÖ¸ÏòµÄ¶ÔÏó½øÐÐÏÞÖÆ£¬Õë¶ÔÉÏÁдúÂë¾ÍÊǶÔa£¬b½øÐÐÏÞÖÆ£¬Ê¹a£¬b²»Äܱ»ÖØи³Öµ£¬Òò´Ë±àÒëʱ»á±¨´í£ºÔÚmianº¯ÊýÖÐÎÞ·¨ÐÞ¸ÄconstÏÞÖƵĶÔÏó¡£µ«Á½¸öÖ¸Õë±äÁ¿µÄÖµÊÇ¿ÉÒÔÐ޸ĵġ£±àÒëÏÂÁдúÂ룺
/* cosntÔÚ*Ç°£¬Ö¸Õë±äÁ¿µÄÖµ¿ÉÒÔÐÞ¸Ä*/
#include <stdio.h>
int main(void)
{
int a=1,b=2;
const int * p1=&a;
int const * p2=&b;
printf ("a=%d\nb=%d\n",*p1,*p2);
p1=&b;
if(p1==p2)
printf("the address of p1 is equal to the address of p2\n");
system("pause");
re
Ïà¹ØÎĵµ£º
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
main()
{
FILE *fp;
if ( (fp = fopen( "c:\\a.txt", "r" )) == NULL ) printf("ERROR!\n");
int tmp[MAXSIZE];
int i;
for ( i=0; i<MAXSIZE; i++ )
{
tmp[i] = 0; ......
ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔÀ´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
memcached_st *memc;
uint32_t&nbs ......
д±¾ÎĵÄÄ¿µÄÊÇΪÁË·½±ã´ó¼ÒÁ˽âC++ MSXML²Ù×÷·½·¨¡£
µ±È»£¬C++ÖжÔMSXMLµÄµ÷ÓÃÓжàÖÖ£¬±¾ÎIJÉÓõķ½·¨ÊÇÍêÈ«²ÎÕÕMSXML SDKÌṩµÄÎĵµ½øÐвÙ×÷¡£
Èç¹ûÓÐʲô´íÎ󣬻¶ÓÖ¸Õý¡£
´úÂë¿ò¼ÜÊÇ»ùÓÚvs2008 MFC ¶Ô»°¿ò³ÌÐò£¨UNICODE£©¡£¶Ô»°¿ò³ÌÐòÐèÒª¶ÁÕß×Ô¼º´´½¨¡£
#include <msxml6.h>
#include <comutil.h>
# ......
EBCDIC (Extended Binary Coded Decimal Interchange Code) À©Ôö¶þ½øʽʮ½ø½»»»Â룬ΪIBMÓÚ1963Äê£1964Äê¼äÍƳöµÄ×Ö·û±àÂë±í£¬¸ù¾ÝÔçÆÚ´ò¿×»úʽµÄ¶þ½ø»¯Ê®½øÊý(BCD, Bindary Coded Decimal)ÅÅÁжø³É¡£ÊÇIBMÃÔ¶û¼¶ÒÔÉϵçÄԵıê×¼Âë¡£
ASCII£¨American Standard Code for Information Interchange£¬ÃÀ¹úÐÅÏ¢»¥»»±ê×¼´úÂë£©Ê ......
C²âÊÔС³ÌÐò
1¡¢ ×Ö·û´®Àà
1.1 strstr
¹¦ÄÜ£º²éÕҺͻñÈ¡×Ó´®
void test_strstr()
{
char *str="Borland Inte ......