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

C/C++±ÊÊÔÃæÊÔÌâÄ¿

1£®ÒÑÖªstrcpy º¯ÊýµÄÔ­ÐÍÊÇ£º
char *strcpy(char *strDest, const char *strSrc);
ÆäÖÐstrDest ÊÇÄ¿µÄ×Ö·û´®£¬strSrc ÊÇÔ´×Ö·û´®¡£²»µ÷ÓÃC++/C µÄ×Ö·û´®¿âº¯Êý£¬Çë±àдº¯Êý strcpy
´ð°¸£º
char *strcpy(char *strDest, const char *strSrc)
{
if ( strDest == NULL || strSrc == NULL)
return NULL ;
if ( strDest == strSrc)
return strDest ;
char *tempptr = strDest ;
while( (*strDest++ = *strSrc++) != ‘’)
;
return tempptr ;
}
2£®ÒÑÖªÀàString µÄÔ­ÐÍΪ£º
class String
{
public:
String(const char *str = NULL); // ÆÕͨ¹¹Ô캯Êý
String(const String &other); // ¿½±´¹¹Ô캯Êý
~ String(void); // Îö¹¹º¯Êý
String & operate =(const String &other); // ¸³Öµº¯Êý
private:
char *m_data; // ÓÃÓÚ±£´æ×Ö·û´®
};
Çë±àдString µÄÉÏÊö4 ¸öº¯Êý¡£
´ð°¸£º
String::String(const char *str)
{
if ( str == NULL ) //strlenÔÚ²ÎÊýΪNULLʱ»áÅ×Òì³£²Å»áÓÐÕâ²½ÅжÏ
{
m_data = new char[1] ;
m_data[0] = '' ;
}
else
{
m_data = new char[strlen(str) + 1];
strcpy(m_data,str);
}
}
String::String(const String &other)
{
m_data = new char[strlen(other.m_data) + 1];
strcpy(m_data,other.m_data);
}
String & String::operator =(const String &other)
{
if ( this == &other)
return *this ;
delete []m_data;
m_data = new char[strlen(other.m_data) + 1];
strcpy(m_data,other.m_data);
return *this ;
}
String::~ String(void)
{
delete []m_data ;
}
3.¼ò´ð
3.1 Í·ÎļþÖеÄifndef/define/endif ¸ÉʲôÓã¿
´ð£º·ÀÖ¹¸ÃÍ·Îļþ±»Öظ´ÒýÓá£
3.2££i nclude <filename.h> ºÍ££i nclude “filename.h” ÓÐʲôÇø±ð£¿
´ð£º¶ÔÓÚ££i nclude <filename.h> £¬±àÒëÆ÷´Ó±ê×¼¿â·¾¶¿ªÊ¼ËÑË÷filename.h
¶ÔÓÚ££i nclude “filename.h”£¬±àÒëÆ÷´ÓÓû§µÄ¹¤×÷·¾¶¿ªÊ¼ËÑË÷filename.h
3.3 ÔÚC++ ³ÌÐòÖе÷Óñ»C ±àÒëÆ÷±àÒëºóµÄº¯Êý£¬ÎªÊ²Ã´Òª¼Óextern “C”£¿
´ð£ºC++ÓïÑÔÖ§³Öº¯ÊýÖØÔØ£¬C ÓïÑÔ²»Ö§³Öº¯ÊýÖØÔØ¡£º¯Êý±»C++±àÒëºóÔÚ¿âÖеÄÃû×ÖÓëC ÓïÑԵIJ»Í¬¡£¼ÙÉèij¸öº¯ÊýµÄÔ­ÐÍΪ£º void foo(int x, int y);
¸Ãº¯Êý±»C ±àÒëÆ÷±àÒëºóÔÚ¿âÖеÄÃû×ÖΪ_foo £¬ ¶øC++ ±àÒëÆ÷Ôò»á²úÉúÏñ_foo_int_int


Ïà¹ØÎĵµ£º

CºÍC++³ÌÐòԱѧϰÀú³Ì

ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
¡¡¡¡Ò»¼ÒÖ®ÑÔ£¬»¶Ó­ÅÄש¹þ¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓÐÓõijÌÐòÔ±£¬×öÒ»¸ö׬ǮµÄ³ÌÐòÔ±¡£ÎÒÃǵļÛÖµ£¬½«ÌåÏÖÔÚ¿Í»§¼ÛÖµÉÏ£¬¶ø²»ÊÇÓï ......

cÖ¸ÕëÏê½â

 µÚÒ»Õ ¸ÅÄî
Ö¸ÕëÊÇÒ»¸öÌØÊâµÄ±äÁ¿£¬ËüÀïÃæ´æ´¢µÄÊýÖµ±»½âÊͳÉΪÄÚ´æÀïµÄÒ»¸öµØÖ·¡£Òª¸ãÇåÒ»¸öÖ¸ÕëÐèÒª¸ãÇåÖ¸ÕëµÄËÄ·½ÃæµÄÄÚÈÝ£ºÖ¸ÕëµÄÀàÐÍ£¬Ö¸ÕëËùÖ¸ÏòµÄÀàÐÍ£¬Ö¸ÕëµÄÖµ»òÕß½ÐÖ¸ÕëËùÖ¸ÏòµÄÄÚ´æÇø£¬»¹ÓÐÖ¸Õë±¾ÉíËùÕ¼¾ÝµÄÄÚ´æÇø¡£ÈÃÎÒÃÇ·Ö±ð˵Ã÷¡£
ÏÈÉùÃ÷¼¸¸öÖ¸Õë·Å×Å×öÀý×Ó£º
ÀýÒ»£º
(1)int *ptr;
(2)char ......

c»ñµÃÎļþ´óС

 1.MFCÖеķ½·¨£º(C++)
CFileStatus status;
CFile::GetStatus("D:\\test.txt",status);
long lSizeOfFile;
lSizeOfFile = status.m_size;
lSizeOfFileµÄÖµ¾ÍÊÇD:\\test.txtÎļþµÄ´óС
2.±ê×¼C»ñµÃÎļþ´óСµÄ5ÖÖ·½·¨
(×¢Ò⣺"__FILE__"Ö¸µÄÊǵ±Ç°Îļþ£¬Äã¿ÉÒÔ¸ÄΪÓÐЧ·¾¶µÄÄ¿±êÎļþ£¬±ÈÈç"D:\\test.txt"£©
#i ......

C/C++Êý×éÃûÓëÖ¸ÕëÇø±ðÉîÈë̽Ë÷

(1)
Êý×éÃûµÄÄÚº­ÔÚÓÚÆäÖ¸´úʵÌåÊÇÒ»ÖÖÊý¾Ý½á¹¹£¬ÕâÖÖÊý¾Ý½á¹¹¾ÍÊÇÊý×飻
(2)
Êý×éÃûµÄÍâÑÓÔÚÓÚÆä¿ÉÒÔת»»ÎªÖ¸ÏòÆäÖ¸´úʵÌåµÄÖ¸Õ룬¶øÇÒÊÇÒ»¸öÖ¸Õë³£Á¿£»
(3)
Ö¸ÏòÊý×éµÄÖ¸ÕëÔòÊÇÁíÍâÒ»ÖÖ±äÁ¿ÀàÐÍ£¨ÔÚWIN32ƽ̨Ï£¬³¤¶ÈΪ4£©£¬½ö½öÒâζ×ÅÊý×éµÄ´æ·ÅµØÖ·
£¨4£©
Êý×éÃû×÷Ϊº¯ÊýÐβÎʱ£¬ÔÚº¯ÊýÌåÄÚ£¬ÆäʧȥÁ˱¾ÉíµÄÄÚº­ ......

²ÉÓÃC++µÄACE¿âʵÏÖµÄÒ»¸öͨÓõÄC/S¼Ü¹¹Í¨ÐųÌÐò

 ACE×ÔÊÊÅäͨÐÅ»·¾³£¨ADAPTIVE Communication Environment£©ÊÇ¿ÉÒÔ×ÔÓÉʹÓᢿª·ÅÔ´ÂëµÄÃæÏò¶ÔÏó£¨OO£©¿ò¼Ü£¨Framework£©£¬ÔÚÆäÖÐʵÏÖÁËÐí¶àÓÃÓÚ²¢·¢Í¨ÐÅÈí¼þµÄºËÐÄģʽ¡£ACEÌṩÁËÒ»×é·á¸»µÄ¿É¸´ÓÃC++ Wrapper Facade£¨°ü×°Íâ¹Û£©ºÍ¿ò¼Ü×é¼þ£¬¿É¿çÔ½¶àÖÖƽ̨Íê³ÉͨÓõÄͨÐÅÈí¼þÈÎÎñ£¬ÆäÖаüÀ¨£ºÊ¼þ¶à··ÖÀëºÍʼþ´¦À ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ