ÏÂÃæÊÇÎÒ¹ØÓÚCÓïÑÔÖи÷ÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ×ܽ᣺(²Î¿¼The C Programming Language)
1. cÓïÑÔÖеÄÕûÊýÀàÐÍÓÐchar, short, int, longµÈ¼¸ÖÖ, ÏÂÃæÊÇCÓïÑÔ¶ÔÿÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ¹æ¶¨:
(a). shortºÍlongÀàÐ͵ij¤¶È²»Ïàͬ
(b). intÀàÐÍͨ³£Í¬¾ßÌå»úÆ÷µÄÎïÀí×Ö³¤Ïàͬ
(c). shortͨ³£ÊÇ16bits, intͨ³£ÊÇ16bits or 32bitsÿÖÖ±àÒëÆ÷¿ÉÒÔ¸ù¾ÝÓ²¼þµÄ²»Í¬×ÔÓÉÈ·¶¨, µ«ÊÇshortºÍint±ØÐë×îÉÙÊÇ16bits, ¶ølongÀàÐͱØÐë×îÉÙÊÇ32bits, ²¢ÇÒshort±ØÐë±ÈintºÍlongÀàÐÍÒª¶Ì¡£
2. sizeof() ÔËËã·û·µ»ØµÄÊÇÒ»ÖÖÊý¾ÝÀàÐÍÖÐËù°üº¬µÄ×Ö½ÚÊý(bytes), AnsiC¹æ¶¨sizeof(char)±ØÐë·µ»Ø1£¬µ±sizeof×÷ÓÃÓÚÊý×éʱ, ·µ»ØµÄÊÇÊý×éÖÐËùÓгÉÔ±ËùÕ¼µÄ×Ö½ÚÊý(×¢Òâ²¢²»ÊÇÊý×éÖгÉÔ±µÄ¸öÊý), µ±sizeof()×÷ÓÃÓڽṹÌåºÍ¹«ÓÃÌåʱ,·µ»ØµÄ²»½ö½öÊÇÊý¾Ý³ÉÔ±×ܵÄ×Ö½ÚÊý, »¹°üÀ¨±àÒëÆ÷ΪÁËʵÏÖ×Ö½Ú¶ÔÆä¶øÌî³äµÄÄÇЩ×Ö½Ú¡£
ÒÔǰд³ÌÐòÒ²ÒþÒþÔ¼Ô¼µÄ¶®µÃÕâЩ¹æÔò£¬µ«ÊÇÒ»Ö±ÒÔΪcharÀàÐͱØÐëÊÇ8bitsµÄ£¬µ«ÊÇ×î½ü×öÁËÒ»¸öǶÈëʽDSPÏîÄ¿£¬±àÒëÆ÷ÊÖ²áÉÏÃ÷Ã÷д×ÅcharÀàÐ;ÍÊÇ16bitsµÄ£¬ÎÞÄη³ö"The C ......
ÏÂÃæÊÇÎÒ¹ØÓÚCÓïÑÔÖи÷ÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ×ܽ᣺(²Î¿¼The C Programming Language)
1. cÓïÑÔÖеÄÕûÊýÀàÐÍÓÐchar, short, int, longµÈ¼¸ÖÖ, ÏÂÃæÊÇCÓïÑÔ¶ÔÿÖÖÊý¾ÝÀàÐͳ¤¶ÈµÄ¹æ¶¨:
(a). shortºÍlongÀàÐ͵ij¤¶È²»Ïàͬ
(b). intÀàÐÍͨ³£Í¬¾ßÌå»úÆ÷µÄÎïÀí×Ö³¤Ïàͬ
(c). shortͨ³£ÊÇ16bits, intͨ³£ÊÇ16bits or 32bitsÿÖÖ±àÒëÆ÷¿ÉÒÔ¸ù¾ÝÓ²¼þµÄ²»Í¬×ÔÓÉÈ·¶¨, µ«ÊÇshortºÍint±ØÐë×îÉÙÊÇ16bits, ¶ølongÀàÐͱØÐë×îÉÙÊÇ32bits, ²¢ÇÒshort±ØÐë±ÈintºÍlongÀàÐÍÒª¶Ì¡£
2. sizeof() ÔËËã·û·µ»ØµÄÊÇÒ»ÖÖÊý¾ÝÀàÐÍÖÐËù°üº¬µÄ×Ö½ÚÊý(bytes), AnsiC¹æ¶¨sizeof(char)±ØÐë·µ»Ø1£¬µ±sizeof×÷ÓÃÓÚÊý×éʱ, ·µ»ØµÄÊÇÊý×éÖÐËùÓгÉÔ±ËùÕ¼µÄ×Ö½ÚÊý(×¢Òâ²¢²»ÊÇÊý×éÖгÉÔ±µÄ¸öÊý), µ±sizeof()×÷ÓÃÓڽṹÌåºÍ¹«ÓÃÌåʱ,·µ»ØµÄ²»½ö½öÊÇÊý¾Ý³ÉÔ±×ܵÄ×Ö½ÚÊý, »¹°üÀ¨±àÒëÆ÷ΪÁËʵÏÖ×Ö½Ú¶ÔÆä¶øÌî³äµÄÄÇЩ×Ö½Ú¡£
ÒÔǰд³ÌÐòÒ²ÒþÒþÔ¼Ô¼µÄ¶®µÃÕâЩ¹æÔò£¬µ«ÊÇÒ»Ö±ÒÔΪcharÀàÐͱØÐëÊÇ8bitsµÄ£¬µ«ÊÇ×î½ü×öÁËÒ»¸öǶÈëʽDSPÏîÄ¿£¬±àÒëÆ÷ÊÖ²áÉÏÃ÷Ã÷д×ÅcharÀàÐ;ÍÊÇ16bitsµÄ£¬ÎÞÄη³ö"The C ......
C++ÖеÄÊý¾ÝÀàÐÍת»»·½·¨×ܽá
ÕªÒª£º±¾ÎÄ×ܽáÁËC/C++ÖеĶàÖÖÊý¾ÝÀàÐÍת»»·½·¨£¬²¢±È½ÏÁ˸÷×ÔµÄÓÅÁÓ¡£¸ø³öÁËÍƼöµÄʹÓý¨Òé¡£
´Óintµ½char*£¬»òÕß·´¹ýÀ´´Óchar*µ½int£¬ÔÚC/C++Öе½µ×ÓжàÉÙÖÖת»»·½·¨ÄØ£¿·ûºÏ±ê×¼µÄ´ó¸ÅÓÐËÄÖÖ¡£¼´CÊý¾Ýת»»º¯Êý×å¡¢sprintf/snprintf/sscanfº¯Êý×å¡¢×Ö·û´®Á÷std::stringstream¡¢std::strsteam¡£²»·ûºÏ±ê׼ȴÓÖ¹ãΪʹÓõİüÀ¨CStringºÍboost::lexical_cast¡£±¾ÎÄÖ»ÌÖÂÛ·ûºÏ±ê×¼µÄת»»·½·¨£¬ÆäÖÐstd::strstreamÓÉÓÚÒѾ±»C++±ê׼ίԱΪָ¶¨Îª²»ÍƼöʹÓõģ¨deprecated£©£¬ËùÒÔ²»Ó迼ÂÇÁË¡£ÏÂÃæÖصãÌÖÂÛÈýÖÖ±ê׼ת»»·½·¨Ö®¼äµÄÓÅÁÓ¡£Ô´´úÂëµÄµØÖ·ÊÇ£ºhttp://download.csdn.net/source/631475
1. IntºÍchar*»òstd::stringÖ®¼äµÄת»»
CÊý¾Ýת»»º¯Êý×å
CÊý¾Ýת»»º¯Êý×å¼´°üÀ¨itoa¡¢atoiµÈÊý¾ÝÀàÐÍת»»º¯ÊýÔÚÄÚµÄÒ»´óÅúCº¯Êý£¬ÔÚCÓïÑÔʱ´úÔø¾±»´óÁ¿Ê¹Óá£Ô´´úÂëÈçÏ£º
int i = 10;
char szBuf[10] = "";
itoa(i, szBuf, 10);
cout<<"itoa: szBuf = "<<szBuf<<endl;
i = 0;
i = atoi(szBuf);
cout<<"atoi: i = "<<i<&l ......
ºÄ·ÑÁËÒ»ÏÂÎ磬Ñо¿ÁËÒ»ÏÂVCµÄÊý¾Ý¿â±à³Ì£¬Ð´ÁËÕâ¸ö²âÊÔ³ÌÐò¡£Ö÷ÒªµÄ¹¦ÄÜΪʵÏÖaccessÊý¾Ý¿âµÄÌí¼ÓÓëɾ³ý£¬Í¬Ê±¶¯Ì¬µÄ½«Êý¾Ý¿âÊý¾ÝÏÔʾÔÚflexgrid¿Ø¼þÖС£ÏÂÃæ°Ñ¹ý³Ì¼Ç¼ÏÂÀ´£¬ÒÔ±¸ºóÓá£
Ò»¡£ADO¼ò½é
ADOÌṩÁËÒ»×é·Ç³£¼òµ¥£¬½«Ò»°ãͨÓõÄÊý¾Ý·ÃÎÊϸ½Ú½øÐзâ×°µÄ¶ÔÏó¡£ÓÉÓÚODBCÊý¾ÝÔ´Ò²ÌṩÁËÒ»°ãµÄOLE DB Privider£¬ËùÒÔADO²»½ö¿ÉÒÔÓ¦ÓÃ×ÔÉíµÄOLE DB Privider£¬¶øÇÒ»¹¿ÉÒÔÓ¦ÓÃËùÓеÄODBCÇý¶¯³ÌÐò¡£¹ØÓÚOLE DBºÍADOµÄÆäËüÏêϸÇé¿ö£¬¶ÁÕß¿ÉÒÔ×ÔÐвéÔÄÏà¹ØÊé¼®»òMSDN£¬ÕâÀï¾Í²»Ò»Ò»ËµÃ÷ÁË¡£ÈÃÎÒÃÇÖ±½Ó²½ÈëÖ÷Ì⣬ÈçºÎÕÆÎÕADOÕâÖÖÊý¾Ý¿â·ÃÎʼ¼ÊõADOµÄ²Ù×÷·½·¨ºÍÇ°Ãæ½²¹ýµÄDAOµÄ²Ù×÷Ôںܶ෽Ãæ´æÔÚÏàËÆÖ®´¦¡£
¶þ¡£Ö÷Òª¿Ø¼þµÄ²¼ÖÃ
³ÌÐòÔËÐÐЧ¹ûÈçͼ£º
1.½øÈ빤³ÌÏòµ¼£¬½¨Á¢»ùÓÚ¶Ô»°¿òµÄmfcÓ¦ÓóÌÐò¡£ÃûΪdatabasetest¡£
¼ÓÈëflexgrid¿Ø¼þ£º¹¤³Ì--->Ìí¼Óµ½¹¤³Ì------->components and controls¡£ÕÒµ½Microsoft Flexgrid control£¬È»ºóinsert¡£Ìí¼Ó¼¸¸östatic box ºÍeditbox£¬Ìí¼ÓÁ½¸öbotton£¬ÊµÏÖ²åÈëºÍɾ³ýµÄ¹¦ÄÜ¡£
2.´ò¿ªaccess2003£¬½¨Á¢¿ÕÊý¾Ý¿âDemo.mdb¡£½¨Á¢±íTable1¡£ÉèÖñàºÅ£¬Ê±¼ä£¬²ÉÑùµãÊý£¬ÀÛ¼Ó´ÎÊý£¬Êý¾Ý5¸ö×ֶΣ¬·Ö±ðΪ×Ô¶¯±àºÅ£¬Ê±¼ä/ÈÕÆÚ£¬Êý×Ö£ ......
C/C++·µ»ØÄÚ²¿¾²Ì¬³ÉÔ±µÄÏÝÚå
³Âð©
±³¾°
ÔÚÎÒÃÇÓÃ
C/C++¿ª·¢µÄ¹ý³ÌÖУ¬×ÜÊÇÓÐÒ»¸öÎÊÌâ»á¸øÎÒÃÇ´øÀ´¿àÄÕ¡£Õâ¸öÎÊÌâ¾ÍÊǺ¯ÊýÄںͺ¯ÊýÍâ´úÂëÐèҪͨ¹ýÒ»¿éÄÚ´æÀ´½»»¥£¨±ÈÈ磬º¯Êý·µ»Ø×Ö·û´®£©£¬Õâ¸öÎÊÌâÀ§
Èźͺܶ࿪·¢ÈËÔ±¡£Èç¹ûÄãµÄÄÚ´æÊÇÔÚº¯ÊýÄÚÕ»ÉÏ·ÖÅäµÄ£¬ÄÇôÕâ¸öÄÚ´æ»áËæן¯ÊýµÄ·µ»Ø¶ø±»µ¯Õ»ÊÍ·Å£¬ËùÒÔ£¬ÄãÒ»¶¨Òª·µ»ØÒ»¿éº¯ÊýÍⲿ»¹ÓÐЧµÄÄÚ´æ¡£
ÕâÊÇÒ»¸öÈÃÎÞÊýÈËÀ§ÈŵÄÎÊÌâ¡£Èç¹ûÄãÒ»²»Ð¡ÐÄ£¬Äã¾ÍºÜÓпÉÄÜÔÚÕâ¸öÉÏÃæ·¸´íÎó¡£µ±È»Ä¿Ç°Óкܶà½â¾ö·½·¨£¬Èç¹ûÄãÊìϤһЩ±ê×¼¿âµÄ»°£¬Äã¿ÉÒÔ¿´µ½Ðí¶à¸÷ʽ¸÷ÑùµÄ½â¾ö·½·¨¡£´óÌåÀ´ËµÓÐÏÂÃ漸ÖÖ£º
1£©
ÔÚº¯ÊýÄÚ²¿Í¨¹ýmalloc»ònewÔÚ¶ÑÉÏ·ÖÅäÄڴ棬Ȼºó°ÑÕâ¿éÄÚ´æ·µ»Ø£¨ÒòΪÔÚ¶ÑÉÏ·ÖÅäµÄÄÚ´æÊÇÈ«¾Ö¿É¼ûµÄ£©¡£ÕâÑù´øÀ´µÄÎÊÌâ¾ÍÊÇDZÔÚµÄÄÚ´æÎÊÌâ¡£Òò
Ϊ£¬Èç¹û·µ»Ø³öÈ¥µÄÄÚ´æ²»ÊÍ·Å£¬ÄÇô¾ÍÊÇmemory
Leak¡£»òÕßÊDZ»¶à´ÎÊÍ·Å£¬´Ó¶øÔì³É³ÌÐòµÄcrash¡£ÕâÁ½¸öÎÊÌⶼÏ൱µÄÑÏÖØ£¬ËùÒÔÕâÖÖÉè¼Æ·½·¨²¢²»ÍƼö¡££¨ÔÚһЩWindows
APIÖУ¬µ±Äãµ÷ÓÃÁËһЩAPIºó£¬Äã±ØÐèÒ²Òªµ÷ÓÃËûµÄijЩAPIÀ´ÊÍ·ÅÕâ¿éÄڴ棩
2£©ÈÃÓû§´«ÈëÒ»¿éËû×Ô¼ºµÄÄÚ´æµØÖ·£¬¶øÔÚº¯ÊýÖаÑÒª
·µ»ØµÄÄÚ´æ·Åµ½Õâ¿éÄÚ´æÖС£ÕâÊÇÒ»¸öÄ¿Ç°ÆÕ±éʹÓõķ½Ê½¡£ºÜ¶àWind ......
C/C++·µ»ØÄÚ²¿¾²Ì¬³ÉÔ±µÄÏÝÚå
³Âð©
±³¾°
ÔÚÎÒÃÇÓÃ
C/C++¿ª·¢µÄ¹ý³ÌÖУ¬×ÜÊÇÓÐÒ»¸öÎÊÌâ»á¸øÎÒÃÇ´øÀ´¿àÄÕ¡£Õâ¸öÎÊÌâ¾ÍÊǺ¯ÊýÄںͺ¯ÊýÍâ´úÂëÐèҪͨ¹ýÒ»¿éÄÚ´æÀ´½»»¥£¨±ÈÈ磬º¯Êý·µ»Ø×Ö·û´®£©£¬Õâ¸öÎÊÌâÀ§
Èźͺܶ࿪·¢ÈËÔ±¡£Èç¹ûÄãµÄÄÚ´æÊÇÔÚº¯ÊýÄÚÕ»ÉÏ·ÖÅäµÄ£¬ÄÇôÕâ¸öÄÚ´æ»áËæן¯ÊýµÄ·µ»Ø¶ø±»µ¯Õ»ÊÍ·Å£¬ËùÒÔ£¬ÄãÒ»¶¨Òª·µ»ØÒ»¿éº¯ÊýÍⲿ»¹ÓÐЧµÄÄÚ´æ¡£
ÕâÊÇÒ»¸öÈÃÎÞÊýÈËÀ§ÈŵÄÎÊÌâ¡£Èç¹ûÄãÒ»²»Ð¡ÐÄ£¬Äã¾ÍºÜÓпÉÄÜÔÚÕâ¸öÉÏÃæ·¸´íÎó¡£µ±È»Ä¿Ç°Óкܶà½â¾ö·½·¨£¬Èç¹ûÄãÊìϤһЩ±ê×¼¿âµÄ»°£¬Äã¿ÉÒÔ¿´µ½Ðí¶à¸÷ʽ¸÷ÑùµÄ½â¾ö·½·¨¡£´óÌåÀ´ËµÓÐÏÂÃ漸ÖÖ£º
1£©
ÔÚº¯ÊýÄÚ²¿Í¨¹ýmalloc»ònewÔÚ¶ÑÉÏ·ÖÅäÄڴ棬Ȼºó°ÑÕâ¿éÄÚ´æ·µ»Ø£¨ÒòΪÔÚ¶ÑÉÏ·ÖÅäµÄÄÚ´æÊÇÈ«¾Ö¿É¼ûµÄ£©¡£ÕâÑù´øÀ´µÄÎÊÌâ¾ÍÊÇDZÔÚµÄÄÚ´æÎÊÌâ¡£Òò
Ϊ£¬Èç¹û·µ»Ø³öÈ¥µÄÄÚ´æ²»ÊÍ·Å£¬ÄÇô¾ÍÊÇmemory
Leak¡£»òÕßÊDZ»¶à´ÎÊÍ·Å£¬´Ó¶øÔì³É³ÌÐòµÄcrash¡£ÕâÁ½¸öÎÊÌⶼÏ൱µÄÑÏÖØ£¬ËùÒÔÕâÖÖÉè¼Æ·½·¨²¢²»ÍƼö¡££¨ÔÚһЩWindows
APIÖУ¬µ±Äãµ÷ÓÃÁËһЩAPIºó£¬Äã±ØÐèÒ²Òªµ÷ÓÃËûµÄijЩAPIÀ´ÊÍ·ÅÕâ¿éÄڴ棩
2£©ÈÃÓû§´«ÈëÒ»¿éËû×Ô¼ºµÄÄÚ´æµØÖ·£¬¶øÔÚº¯ÊýÖаÑÒª
·µ»ØµÄÄÚ´æ·Åµ½Õâ¿éÄÚ´æÖС£ÕâÊÇÒ»¸öÄ¿Ç°ÆÕ±éʹÓõķ½Ê½¡£ºÜ¶àWind ......
½ñÌì¿´¡¶C++ Templates¡·£¬¿´µ½Ò»¸ö·ÇÀàÐÍÄ£°åʵ²ÎµÄÀý×ÓÖÐÓÐÕâÑùµÄ´úÂ룺
template <typename T, T nontype_param>
class C;
class X{
public:
int n;
static bool b;
};
C<int X::*, &X::n>* c5;
X::*¿ÉÒÔ±íʾXÀàµÄ³ÉÔ±µÄÖ¸Õ룬ÓÃÓÚ±íʾÀàÐÍ£¬µÚÒ»´Î¼û£¬ºÜ¾ªÆ棬¼ÇÏÂÁË¡£C++¹ûȻǿ´ó¡£ ......
ÔõÑù¼ÓÔØÆäËûµÄÓ¦ÓóÌÐò?
Èý¸öSDKº¯Êý winexec,
shellexecute,createprocess¿ÉÒÔʹÓá£WinExec×î¼òµ¥£¬Á½¸ö²ÎÊý£¬Ç°Ò»¸öÖ¸¶¨Â·¾¶£¬ºóÒ»¸öÖ¸¶¨ÏÔʾ·½Ê½.ºóÒ»¸ö²ÎÊýÖµµÃ
˵һÏ£¬±ÈÈçÄàÓÃ
SW_SHOWMAXMIZED·½Ê½È¥¼ÓÔØÒ»¸öÎÞ×î´ó»¯°´Å¥µÄ³ÌÐò£¬¾ÍÊÇNeterm,calcµÈµÈ£¬¾Í²»»á³öÏÖÕý³£µÄ´°Ì壬µ«ÊÇÒѾ±»¼Óµ½ÈÎÎñÁбíÀï
ÁË¡£
ShellExecute½Ï WinExexÁé»îÒ»µã£¬¿ÉÒÔÖ¸¶¨¹¤×÷Ŀ¼,ÏÂÃæµÄExample¾ÍÊÇÖ±½Ó´ò¿ª
c:\temp\1.txt,¶ø²»ÓüÓÔØÓë txtÎļþ¹ØÁªµÄÓ¦ÓóÌÐò,ºÜ¶à°²×°³ÌÐòÍê³Éºó¶¼»á´ò¿ªÒ»¸ö´°¿Ú£¬À´ÏÔʾReadme or
Faq,ÎҲ¾ÍÊÇÕâô×÷µÄÀ².
ShellExecute(NULL,NULL,_T("1.txt"),NULL,_T("c:\\temp"),SW_SHOWMAXMIZED)
CreateProcess×ÔÓ£¬Ò»¹²ÓÐÊ®¸ö²ÎÊý£¬²»¹ý´ó²¿·Ö¶¼¿ÉÒÔÓÃNULL´úÌ棬Ëü¿ÉÒÔÖ¸¶¨½ø³ÌµÄ°²È«ÊôÐÔ£¬¼Ì³ÐÐÅÏ¢£¬ÀàµÄÓÅÏȼ¶µÈµÈ.À´¿´¸öºÜ¼òµ¥µÄExample:
STARTUPINFO stinfo
//Æô¶¯´°¿ÚµÄÐÅÏ¢
PROCESSINFO procinfo //½ø³ÌµÄÐÅÏ¢
CreateProcess(NULL,_T("notepad.exe"),NULL,NULL.FALSE,
NORMAL_PRIORITY_
CLASS,NULL,NULL, &stinfo,&procinfo)
³£ÓþÙÀý£º1¡¢º¯Êý£ºsystem ......