C ÓïÑÔÖеÄÀàÐÍת»»ÎÊÌâ
C ÓïÑÔÖеÄÀàÐÍת»»ÎÊÌâ
Ò»¡¢ÎÊÌâµÄÒý³ö
¿´ÏÂÃæÒ»¶Î C ³ÌÐò£º
#include <stdio.h>
int main()
{
short a, b;
float f;
double d;
int i1, i2;
i1 = i2 = 2000000000; //²âÊÔ»·¾³ÖÐ int µÄ±íʾ·¶Î§Îª -2147483648 ~ 2147483647
printf("%d\n", i1+i2); //Òç³ö£¡
a = b = 30000; //²âÊÔ»·¾³ÖÐ short µÄ±íʾ·¶Î§Îª -32768 ~ 32767
printf("%d\n", a+b); //Òç³ö£¿
f = d = 123456789.0;
printf("%f\n", f); //Õý³£Êä³ö£¿
printf("%f\n", d); //Õý³£Êä³ö£¿
return 0;
}
ÔËÐгÌÐòÎÒÃÇ¿´µ½£¬i1+i2 µÄ½á¹ûÀíËùÓ¦µ±µØÒç³öÁË£¬¶ø a+b µÄ½á¹ûȴûÓÐÏñÏëÏóÖеÄÄÇÑùÒç³öΪһ¸ö¸ºÊý¡£
ÁíÍ⣬printf ÖУ¬%f ¶ÔÓÚ float ºÍ double Ð͵ÄÖµ¶¼Äܹ»ÕýÈ·Êä³ö¡£È»¶øÔÚ´ó¶àÊýϵͳÉÏ£¬float ºÍ double µÄÄÚ´æ½á¹¹²¢²»Ïàͬ¡£
ÀàËƵأ¬%d Ò²ÄÜͬʱ½ÓÊÕ short ºÍ int Ð͵ÄÊý¾Ý¡£
ÈçºÎ½âÊÍÉÏÃæµÄÏÖÏó£¿
¶þ¡¢ÎÊÌâµÄ½â´ð——ĬÈÏÀàÐÍת»»
C ÓïÑԹ涨ÁËÒ»ÀàÀàÐÍת»»£¬³Æ×÷“³£ÓÃËãÊõÀàÐÍת»»”£¨Usual arithmetic conversions£©£¬ÓÃÓÚ±í´ïʽÇóÖµµÄÀàÐ͵÷Õû£¬³£¼ûµÄ“µÍ¾«¶ÈÀàÐÍÏò¸ß¾«¶ÈÀàÐÍ¿¿”µÄ˵·¨¼´³öÓÚ´Ë¡£
1¡¢¼¸¸öÖØÒª¸ÅÄî
(1) ËãÊõ£¨arithmetic£©ÀàÐÍ£º°üÀ¨ÕûÐͺ͸¡µãÐÍ£¨ÊµÊýºÍ¸´Êý£©
(2) ±êÁ¿£¨scalar£©ÀàÐÍ£º°üÀ¨ËãÊõÀàÐͺÍÖ¸ÕëÀàÐÍ
(3) ¼¯ºÏ£¨aggregate£©ÀàÐÍ£º°üÀ¨Êý×éÀàÐͺͽṹÀàÐÍ
ÉÏÃæµÄ (2) ºÍ (3) ÕâÀïûÓÐÓõ½£¬Ö÷ÒªÊÇΪÁËÍêÕûÐԺͷ½±ãÔĶÁ±ê×¼Ìá³ö¡£
2¡¢ÕýʽÌÖÂÛ
(1) ÕûÊýÀàÐÍÌáÉý£¨integer promotions£©
¡¡¡¡ÊÊÓöÔÏó£º±È int ºÍ unsigned int µÍ¼¶µÄÕûÊýÀàÐÍ»òÕß _Bool, int, signed int ºÍ unsigned int µÄ“λÓò”ÀàÐÍ¡£
¡¡¡¡²Ù×÷£ºÈç¹û int ¿ÉÒÔÈÝÄɱ»×ª»»ÀàÐ͵ÄÒ»ÇÐÈ¡Öµ£¬ÔòÌáÉýÖÁ int£¬·ñÔòÌáÉýÖÁ unsigned int¡£
(2) ³£ÓÃËãÊõÀàÐÍת»»£¨Usual arithmetic conversions£©µÄ¹ý³Ì
¡¡¡¡¢ÙÈç¹ûÓи¡µãÊý£¬°´ÕÕ float -> double -> long double µÄ¼¶±ðת»»ÖÁ½Ï¸ßµÄÀàÐÍ¡£
¡¡¡¡¢Ú·ñÔò£¬Ê×ÏÈ×öÕûÊýÀàÐÍÌáÉý£¬È»ºó½«ÌáÉýºóµÄÀàÐÍÔÙ°´ÕûÐͼ¶±ðת»»ÖÁ½Ï¸ßÀàÐÍ¡£
(3) ÒªÇó“³£ÓÃËãÊõÀàÐÍת»»”µÄÇéÐÎ
¡¡¡¡¢Ùµ¥Ä¿ÊýÖµÔËËã·û£¨+, -, ~£©£¬²»°üÀ¨£¨!£©
¡¡¡¡¢Ú³Ë·¨ÐÔÔËËã·û£¨*, /, %£©
¡¡¡¡¢Û¼Ó·¨ÐÔÔËËã·û£¨+, -£©ÖУ¬µ±Á½²àµÄ²Ù×÷Êý¶¼ÊÇËãÊõÀàÐ͵Äʱºò
¡¡¡¡¢
Ïà¹ØÎĵµ£º
µ±ÔÚC Öж¨ÒåÁËÒ»¸ö½á¹¹ÀàÐÍʱ£¬ËüµÄ´óСÊÇ·ñµÈÓÚ¸÷×Ö¶Î(field) ´óС֮ºÍ£¿±àÒëÆ÷½«ÈçºÎÔÚÄÚ´æÖзÅÖÃÕâЩ×ֶΣ¿ANSI C¶Ô½á¹¹ÌåµÄÄÚ´æ²¼¾ÖÓÐʲôҪÇ󣿶øÎÒÃǵijÌÐòÓÖÄÜ·ñÒÀÀµÕâÖÖ²¼¾Ö£¿ÕâЩÎÊÌâ»òÐí¶Ô²»ÉÙÅóÓÑÀ´Ëµ»¹ÓеãÄ£ºý£¬ÄÇô±¾ÎľÍÊÔ×Å̽¾¿ËüÃDZ³ºóµÄÃØÃÜ¡£
Ê×ÏÈ£¬ÖÁÉÙÓÐÒ»µã¿ÉÒԿ϶¨£¬ÄǾÍÊÇANSI C ±£Ö¤½á¹¹ÌåÖи÷× ......
constÊÇÒ»¸öCÓïÑԵĹؼü×Ö£¬ËüÏÞ¶¨Ò»¸ö±äÁ¿²»ÔÊÐí±»¸Ä±ä¡£Ê¹ÓÃconstÔÚÒ»¶¨³Ì¶ÈÉÏ¿ÉÒÔÌá¸ß³ÌÐòµÄ½¡×³ÐÔ£¬ÁíÍ⣬ÔÚ¹Û¿´±ðÈË´úÂëµÄʱºò£¬ÇåÎúÀí½âconstËùÆðµÄ×÷Ó㬶ÔÀí½â¶Ô·½µÄ³ÌÐòÒ²ÓÐһЩ°ïÖú¡£
¡¡¡¡ËäÈ»ÕâÌýÆðÀ´ºÜ¼òµ¥£¬µ«Êµ¼ÊÉÏ£¬constµÄʹÓÃÒ²ÊÇcÓïÑÔÖÐÒ»¸ö±È½Ï΢ÃîµÄµØ·½£¬Î¢ÃîÔںδ¦ÄØ£¿Çë¿´ÏÂÃ漸¸öÎÊÌâ¡£
¡¡¡¡ÎÊÌâ ......
Ò»¼ÒÖ®ÑÔ£¬»¶ÓÅÄש¹þ¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû³ÉΪһ¸ö½â¾öÎÊÌâµÄר¼Ò¡£×öÒ»¸öÓÐÓõijÌÐòÔ±£¬×öÒ»¸ö׬ǮµÄ³ÌÐòÔ±¡£ÎÒÃǵļÛÖµ£¬½«ÌåÏÖÔÚ¿Í»§¼ÛÖµÉÏ£¬¶ø²»ÊÇÓïÑÔдµÃºÃ²»ºÃ¿´¡£
¡¡¡¡C++ÊÇCµÄÒ»¸öÃæÏò¶ÔÏóµÄ½âÊÍ£¬C++ΪCÀ©³äÁË´ó¹æÄ£¹¤³ÌÓ¦ ......
C/C++µÄ¶ÑÕ»£¬ÄÚ´æ·ÖÅä
2008Äê12ÔÂ02ÈÕ ÐÇÆÚ¶þ 11:51
Ò»¡¢Ò»¸ö¾¹ý±àÒëµÄC/C++µÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·Ö³ÉÒÔϼ¸¸ö²¿·Ö£º
1¡¢Õ»Çø£¨stack£©£ºÓɱàÒëÆ÷×Ô¶¯·ÖÅäºÍÊÍ·Å £¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ¡¢¾Ö²¿±äÁ¿µÄÖµµÈ£¬ÉõÖÁº¯ÊýµÄµ÷Óùý³Ì¶¼ÊÇÓÃÕ»À´Íê³É¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© £ºÒ»°ãÓɳÌÐòÔ±ÊÖ¶¯ÉêÇëÒÔ¼°ÊÍ ......
Visual Studio°üº¬ÁË4¸ö±¾»úC/C++ÔËÐÐʱ¿âºÍ2¸öÓÃÀ´¹ÜÀíMS.NETµÄC/C++ÔËÐÐʱ¿â¡£ËùÓÐÕâЩ¿â¶¼Ö§³Ö¶àÏ̱߳à³Ì»·¾³£ºÄ¿Ç°ÒѾûÓÐרÃÅΪµ¥Ï߳̿ª·¢Éè¼ÆµÄC/C++ÔËÐÐʱ¿âÁË¡£±í6-1¶ÔÕâЩ¿â½øÐÐÁËÃèÊö£º
Libray Name
Description
LibCMt.lib
Statically linked release version of the library.
Lib ......