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

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"¹ýÁËÉúÃüÆÚ£¬²»ÔÚÄÚ´æÁË


Ïà¹ØÎĵµ£º

C Cpp IDE

from£ºhttp://wiki.ubuntu.org.cn/index.php?title=C_Cpp_IDE&variant=zh-cn
¼øÓÚ²»¶ÏÓÐÍøÓѽ«±àÒëÆ÷ GCC ÎóÈÏΪ IDE£¨¼¯³É¿ª·¢»·¾³£©
ÆÚÍûÍÑÀëÃüÁîÐÐ
ÆÚÍûÄÜÔڲ˵¥Öз¢ÏÖÆäÉíÓ°
ÆÚÍûÆäÄÜÓÐÒ»¸ö¼¯±à¼­±àÒëÁ´½Óµ÷ÊÔÔËÐÐÓÚÒ»ÌåµÄ½çÃæ
¹Ê±¾Îĸø´ó¼Ò¼òµ¥ÂÞÁÐһЩ C/C++ ±à³ÌÖпÉÓÃµÄ IDE£¬»òÐíÄã´ÓÖпÉÒÔÕÒÒ»¸öÄãϲ»¶µ ......

C unsigned int and int

Ê×ÏȽøÐÐÒ»¸öʵÑ飬·Ö±ð¶¨ÒåÒ»¸ösigned intÐÍÊý¾ÝºÍunsigned intÐÍÊý¾Ý£¬È»ºó½øÐдóС±È½Ï£º
unsigned int a=20;
signed int b=-130;
a>b?»¹ÊÇb>a£¿ÊµÑéÖ¤Ã÷b>a£¬Ò²¾ÍÊÇ˵£­130>20,Ϊʲô»á³öÏÖÕâÑùµÄ½á¹ûÄØ£¿
ÕâÊÇÒòΪÔÚCÓïÑÔ²Ù×÷ÖУ¬Èç¹ûÓöµ½ÎÞ·ûºÅÊýÓëÓзûºÅÊýÖ®¼äµÄ²Ù×÷£¬±àÒëÆ÷»á×Ô¶¯×ª»¯ÎªÎÞ·ûºÅ ......

c ÓïÑÔÖеÄ×Ö·û´®²Ù×÷

http://blog.chinaunix.net/u1/41817/showart_342390.html
6£®5       
ÔõÑù½«×Ö·û´®´òÓ¡³ÉÖ¸¶¨³¤¶È
?   
 
   
Èç¹ûÒª°´±í¸ñÐÎʽ´òÓ¡Ò»×é×Ö·û´®£¬Äã¾ÍÐèÒª½«×Ö·û´®´òÓ¡³ÉÖ¸¶¨³¤¶È¡£ÀûÓÃ
printf()º¯Êý¿ÉÒԺܷ½±ãµØÊµÏÖÕâÒ»µã£¬Çë¿´ÏÂÀý
......

ubuntuϱàÒëc/c++

ÈôÏëÔÚubuntuϱàÒëc/c++´úÂë
Ê×ÏÈ£¬°²×°g++ºÍgdb£¬¿ÉÒÔÔÚÐÂÁ¢µÃÖÐÖ±½Ó°²×°
ÈôÒª±àÒëc£¬È磺
££include
<stdio.h>
int main()
{
   
printf("Hello,World!\n");
    return 0;

}




......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ