C/C++ ÃæÊÔÌâ
µÚÒ»Ì⣺
ÏÂÃæ³ÌÐòµÄÊä³ö½á¹û£¿
#include <stdio.h>
#include <iostream>
void main()
{
char str1[] = "";
char str2[] = "";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
char* str7="abc";
char* str8="abc";
std::cout << std::boolalpha << ( str1==str2 ) << std::endl; // Êä³öʲô£¿
std::cout << std::boolalpha << ( str3==str4 ) << std::endl; // Êä³öʲô£¿
std::cout << std::boolalpha << ( str5==str6 ) << std::endl; // Êä³öʲô£¿
std::cout << std::boolalpha << ( str7==str8 ) << std::endl; // Êä³öʲô£¿
int i;
scanf("%d",&i);
}
½á¹û:false,false,true,true. ÒòΪǰÁ½¸öµÄÄÚ´æÊÇÔÚheapÉÏ·ÖÅäµÄ£¬µ±È»ÊDz»Í¬µÄµØÖ·£»¶øºóÁ½¸öÊÇÔÚ¾²Ì¬Çø·ÖÅäµÄ£¬ºóÃæµÄÏȼì²éÇ°ÃæÓÐÎÞ¸Ã×Ö·û´®£¬Óеϰ£¬¾Í²»ÔÙ·ÖÅ䣬ËùÒÔstr5,str6,str7,str8µØÖ·¶¼ÊÇÏàͬµÄ¡£
µÚ¶þÌâ:
1.¼ì²éÏÂÃæ³ÌÐòÊÇ·ñÓдíÎó²¢Ð´³öÔËÐнá¹û
(1).
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world");
printf(str);
}
(2).
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
(3).
void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory2(&str, 100);
strcpy(str, "hello");
printf(str);
}
½á¹û:(1)³ÌÐò±ÀÀ£¡£ÒòΪstr²¢Î´±»¸³Öµ£¬ÈÔÈ»ÊÇ0;
(2)¿ÉÄÜÊÇÂÒÂë¡£ÒòΪ"hello world"¹ýÁËÉúÃüÆÚ£¬²»ÔÚÄÚ´æÁË
Ïà¹ØÎĵµ£º
http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html
Sunday, May 10, 2009
Hadoop should target C++/LLVM, not Java (because of watts)
< type="text/javascript">
digg_url="http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html";
Over the years, ......
from£ºhttp://wiki.ubuntu.org.cn/index.php?title=C_Cpp_IDE&variant=zh-cn
¼øÓÚ²»¶ÏÓÐÍøÓѽ«±àÒëÆ÷ GCC ÎóÈÏΪ IDE£¨¼¯³É¿ª·¢»·¾³£©
ÆÚÍûÍÑÀëÃüÁîÐÐ
ÆÚÍûÄÜÔڲ˵¥Öз¢ÏÖÆäÉíÓ°
ÆÚÍûÆäÄÜÓÐÒ»¸ö¼¯±à¼±àÒëÁ´½Óµ÷ÊÔÔËÐÐÓÚÒ»ÌåµÄ½çÃæ
¹Ê±¾Îĸø´ó¼Ò¼òµ¥ÂÞÁÐһЩ C/C++ ±à³ÌÖпÉÓÃµÄ IDE£¬»òÐíÄã´ÓÖпÉÒÔÕÒÒ»¸öÄãϲ»¶µ ......
1.staticÓÐʲôÓÃ;£¿£¨ÇëÖÁÉÙ˵Ã÷Á½ÖÖ£©
1)ÔÚº¯ÊýÌ壬һ¸ö±»ÉùÃ÷Ϊ¾²Ì¬µÄ±äÁ¿ÔÚÕâÒ»º¯Êý±»µ÷Óùý³ÌÖÐά³ÖÆäÖµ²»±ä¡£
2) ÔÚÄ£¿éÄÚ£¨µ«ÔÚº¯ÊýÌåÍ⣩£¬Ò»¸ö±»ÉùÃ÷Ϊ¾²Ì¬µÄ±äÁ¿¿ÉÒÔ±»Ä£¿éÄÚËùÓú¯Êý·ÃÎÊ£¬µ«²»Äܱ»Ä£¿éÍâÆäËüº¯Êý·ÃÎÊ¡£ËüÊÇÒ»¸ö±¾µØµÄÈ«¾Ö±äÁ¿¡£
......
ÓÉÓÚVC±àÒëÆ÷Óк¯ÊýÖØÃüÃûµÄ¹¦ÄÜËùÒÔ£¬È·¶¨º¯ÊýÃûÓÐÁ½ÖÖ·½Ê½£º
1.extern "C"
2.ʹÓÃ.defÎļþ
ÕâÁ½ÖÖÒ²¿ÉÒÔÒ»ÆðʹÓá£
ÏÂÃæÊÇÒ»¸öÀý×Ó£º
extern "C" _declspec(dllexport)int __stdcall JieCheng(int a)
{//½×³Ëº¯Êý¡£ÊäÈë:ÕýÕûÊý¡£Êä³ö:Õâ¸öÊýµÄ½×³ËÖµ
int b=1;
for(int i=1;i<=a;i++)
{
&n ......
À´×ÔÒ»±¾¾ø°æµÄÊé,ËäȻûÓк¯Êý
ÃèÊö,µ«ÊÇ×îÆðÂë¿ÉÒÔÖªµÀ·ÖÀà,¾Í¿ÉÒÔÈ¥ man ÁË
Linux Cº¯Êý¿â²Î¿¼ÊÖ²á
µÚ1ÕÂ×Ö·û²âÊÔ
º¯Êý
isalnum(²âÊÔ×Ö·ûÊÇ·ñΪӢÎÄ×Öĸ»òÊý×Ö)
isalpha(²âÊÔ×Ö·ûÊÇ·ñΪӢÎÄ×Öĸ)
isascii(²âÊÔ×Ö·ûÊÇ·ñΪASCIIÂë×Ö·û)
isblank(²âÊÔ×Ö·ûÊÇ·ñΪ¿Õ¸ñ×Ö·û)
iscntrl(²âÊÔ×Ö·ûÊÇ·ñΪASCIIÂëµÄ¿ØÖÆ×Ö·û ......