c/c++±ÊÊÔÌâÄ¿(ÁÖÈñ)
±¾ÊÔÌâ½öÓÃÓÚ¿¼²éC++/C³ÌÐòÔ±µÄ»ù±¾±à³Ì¼¼ÄÜ¡£ÄÚÈÝÏÞÓÚC++/C³£ÓÃÓï·¨£¬²»Éæ¼°Êý¾Ý½á¹¹¡¢Ëã·¨ÒÔ¼°Éî°ÂµÄÓï·¨¡£¿¼ÊԳɼ¨ÄÜ·´Ó³³ö¿¼ÉúµÄ±à³ÌÖÊÁ¿ÒÔ¼°¶ÔC++/CµÄÀí½â³Ì¶È£¬µ«²»ÄÜ·´Ó³¿¼ÉúµÄÖÇÁ¦ºÍÈí¼þ¿ª·¢ÄÜÁ¦¡£
±ÊÊÔʱ¼ä90·ÖÖÓ¡£Ç뿼ÉúÈÏÕæ´ðÌ⣬ÇÐÎðÇáÊÓ¡£
Ò»¡¢ÇëÌîдBOOL , float, Ö¸Õë±äÁ¿ Óë“ÁãÖµ”±È½ÏµÄ if Óï¾ä¡££¨10·Ö£©
Ìáʾ£ºÕâÀï“ÁãÖµ”¿ÉÒÔÊÇ0, 0.0 , FALSE»òÕß“¿ÕÖ¸Õ딡£ÀýÈç int ±äÁ¿ n Óë“ÁãÖµ”±È½ÏµÄ if Óï¾äΪ£º
if ( n == 0 )
if ( n != 0 )
ÒÔ´ËÀàÍÆ¡£
¡¡
Çëд³ö BOOL flag Óë“ÁãÖµ”±È½ÏµÄ if Óï¾ä£º
¡¡
Çëд³ö float x Óë“ÁãÖµ”±È½ÏµÄ if Óï¾ä£º
¡¡
Çëд³ö char *p Óë“ÁãÖµ”±È½ÏµÄ if Óï¾ä£º
¡¡
¡¡
¶þ¡¢ÒÔÏÂΪWindows NTϵÄ32λC++³ÌÐò£¬Çë¼ÆËãsizeofµÄÖµ£¨10·Ö£©
char str[] = “Hello” ;
char *p = str ;
int n = 10;
Çë¼ÆËã
sizeof (str ) =
sizeof ( p ) =
sizeof ( n ) =
void Func ( char str[100])
{
Çë¼ÆËã
sizeof( str ) =
}
¡¡
void *p = malloc( 100 );
Çë¼ÆËã
sizeof ( p ) =
¡¡
Èý¡¢¼ò´ðÌ⣨25·Ö£©
1¡¢Í·ÎļþÖÐµÄ ifndef/define/endif ¸ÉʲôÓã¿
¡¡
2¡¢#include <filename.h> ºÍ #include “filename.h” ÓÐʲôÇø±ð£¿
¡¡
3¡¢const ÓÐʲôÓÃ;£¿£¨ÇëÖÁÉÙ˵Ã÷Á½ÖÖ£©
¡¡
4¡¢ÔÚC++ ³ÌÐòÖе÷Óñ» C±àÒëÆ÷±àÒëºóµÄº¯Êý£¬ÎªÊ²Ã´Òª¼Ó extern “C”ÉùÃ÷£¿
¡¡
5¡¢Çë¼òÊöÒÔÏÂÁ½¸öforÑ»·µÄÓÅȱµã
// µÚÒ»¸ö
for (i=0; i<N; i++)
{
if (condition)
DoSomething();
else
DoOtherthing();
}
// µÚ¶þ¸ö
if (condition)
{
for (i=0; i<N; i++)
DoSomething();
}
else
{
for (i=0; i<N; i++)
DoOtherthing();
}
Óŵ㣺
ȱµã£º
Óŵ㣺
ȱµã£º
¡¡
ËÄ¡¢ÓйØÄÚ´æµÄ˼¿¼Ì⣨20·Ö£©
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world");
printf(str);
}
ÇëÎÊÔËÐÐTestº¯Êý»áÓÐʲôÑùµÄ½á¹û£¿
´ð£º
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
Ïà¹ØÎĵµ£º
/*
coder: ACboy
date: 2010-3-14
result: 1A
description: UVa 327 Evaluating Simple C Expressions
*/
#include <iostream>
#include <algorithm>
using namespace std;
struct Node {
char name;
int value;
int lastValue;
int pos;
};
int cmp(const Node & a, const Node &a ......
ΪÁËÓÃvcдһ¸ö×î¼òµ¥µÄ socket ³ÌÐò£¬»¨·ÑÁËÒ»¸öÏÂÎçµÄʱ¼ä£¬¹ý³ÌÖгöÏֵĴíÎóÓУº
'SOCKET' : illegal use of this type as an expression
syntax error : missing ';' before 'type'
syntax error : identifier 'InitWinsock' --> bool InitWinsock( ......
Á´½Óָʾ·ûextern C
Èç¹û³ÌÐòԱϣÍûµ÷ÓÃÆäËû³ÌÐòÉè¼ÆÓïÑÔÓÈÆäÊÇC дµÄº¯ÊýÄÇôµ÷Óú¯Êýʱ±ØÐë
¸æËß±àÒëÆ÷ʹÓò»Í¬µÄÒªÇóÀýÈçµ±ÕâÑùµÄº¯Êý±»µ÷ÓÃʱº¯ÊýÃû»ò²ÎÊýÅÅÁеÄ˳Ðò¿ÉÄÜ
²»Í¬ÎÞÂÛÊÇC++º¯Êýµ÷ÓÃËü»¹ÊÇÓÃÆäËûÓïÑÔдµÄº¯Êýµ÷ÓÃËü
³ÌÐòÔ±ÓÃÁ´½Óָʾ·ûlinkage directive ¸æËß±àÒëÆ÷¸Ãº¯ÊýÊÇÓÃÆäËûµÄ³ÌÐòÉè¼ÆÓïÑÔ
±àдµ ......
½ñÌìͻȻÏëµ½B/S½á¹¹ÀwebformÊÇÎÞ·¨È¡µÃ¿Í»§¶ËµÄMACµØÖ·ºÍÓ²¼þÐÅÏ¢µÄ£¬¾ÍÍ»·¢ÆæÏ룬ÓÃC/S½á¹¹£¬µ«ÊÇÒòΪC/S½á¹¹µÄºÜ¶àµÄ¶«Î÷²»Äܶ¯Ì¬£¬¾Í¿¼Âǵ½ÁËC/B½á¹¹
×îºó¾ö¶¨ÓÃwebservice+ALC+C/B½á¹¹ £¬´î½¨ÎÒµÄOAϵͳ
ŬÁ¦ing ......