Uֵ}(zh)~
P(gun)cZ(y)ԵĎׂ(g)}

һՈ(xi)BOOL , float, ָ׃ c“ֵ”^ if Z(y)10֣
Ո(xi) BOOL flag c“ֵ”^ if Z(y)3֣
˜ʴ𰸣
if ( flag )
if ( !flag ) (xi)ٲL(fng)÷
if (flag == TRUE)
if (flag == 1 )
if (flag == FALSE)
if (flag == 0)
Ո(xi) float x c“ֵ”^ if Z(y)4֣
˜ʴʾ
const float EPSINON = 0.00001;
if ((x >= - EPSINON) && (x <= EPSINON)
Ɍc(din)׃“==”“=”cֱ^ԓOD“>=”“<=”
(li)
ʽ
e`Č(xi)÷
if (x == 0.0)
if (x != 0.0)
Ո(xi) char *p c“ֵ”^ if Z(y)3֣
˜ʴ𰸣
if (p == NULL)
if (p != NULL) (xi)ٲL(fng)÷
if (p == 0)
if (p != 0)
if (p)
if (!)
Windows NTµ32λC++ՈӋsizeofֵ10֣
char str[] = “Hello” ;
char *p = str ;
int n = 10;
ՈӋ
sizeof (str ) = 6 2֣
sizeof ( p ) = 4 2֣
sizeof ( n ) = 4 2֣ void Func ( char str[100])
{
ՈӋ
sizeof( str ) = 4 2֣
}
void *p = malloc( 100 );
ՈӋ
sizeof ( p ) = 4 2֣
(jin)}25֣
1^ļе ifndef/define/endif ʲô5֣
𣺷ֹԓ^ļ؏
2#include #include “filename.h” ʲô^e5֣
𣺌#include gĘ˜ʎ·_(ki)ʼ filename.h
#include “filename.h” gÑ(h)Ĺ·_(ki)ʼ filename.h
3const ʲô;Ոf(shu)ɷN5֣
𣺣1Զx const
2constąֵĶxwconstĖ|
ܵ
ƱoA׃(dng)߳Ľ
4C++ {ñ CggĺʲôҪ extern “C” 5
C++Z(y)ֺ֧dCZ(y)Բֺ֧dC++gڎе
c
CZ(y)
IJͬOij(g)ԭ͞飺 void foo(int x, int y);
ԓCggڎе֞_(ki)fooC++gt(hu )a(chn)_foo_int_in
t
֮(li)
C++ṩCBӽQָ̖extern“C”(li)Qƥ䆖(wn)}
5Ո(jin)ɂ(g)forѭh(hun)ă(yu)ȱc(din)5֣
for (i=0; iN; i++)
{
if (condition)
DoSomething();
else
DoOtherthing();
}
if (condition)
{
for (i=0; iN; i++)
DoSomething();
}
else
{
for (i=0; iN; i++)
DoOtherthing();
}
(yu)c(din)(jin)
ȱc(din)N-1߉ДҴѭh(hun)“ˮ(xin)”I(y)ʹþg
ѭh(hun)M(jn)Ѓ(yu)̎Ч (yu)c(din)ѭh(hun)Чʸ
ȱc(din)(jin)
P(gun)ȴ˼}ÿС}520֣
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world");
printf(str);
}
Ո(wn)\Test(hu )ʲôӵĽY
𣺳
GetMemory܂f(dng)B(ti)ȴ
Testе strһֱ NULL
strcpy(str, "hello world");ʹ
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
Ո(wn)\Test(hu )ʲôӵĽY
𣺿ǁya
GetMemoryصָ“ȴ”ָԓָᘵĵַ NULLԭ
F
ѽ(jng)ݲ֪
void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
printf(str);
}
Ո(wn)\Test(hu )ʲôӵĽY
1܉ݔhello
2ȴй©
void Test(void)
{
char *str = (char *) malloc(100);
strcpy(str, “hello”);
free(str);
if(str != NULL)
{
strcpy(str, “world”);
printf(str);
}
}
Ո(wn)\Test(hu )ʲôӵĽY
𣺴۸Ą(dng)B(ti)ȴ^ăyAdzΣU
free(str);֮strɞҰָ
if(str != NULL)Z(y)䲻
(xi)strcpy10֣
֪strcpyԭ
char *strcpy(char *strDest, const char *strSrc);
strDestĿַstrSrcԴַ
1{C++/Cַ캯Ո(xi) strcpy
char *strcpy(char *strDest, const char *strSrc);
{
assert((strDest!=NULL) && (strSrc !=NULL)); /pic/>
char *address = strDest; /pic/>
while( (*strDest++ = * strSrc++) != ‘一级日韩免费大片,亚洲一区二区三区高清,性欧美乱妇高清come,久久婷婷国产麻豆91天堂,亚洲av无码a片在线观看