ÿÈÕC(4.×Ö·û´®×ª»»Æª)
×Ö·û´®×ª»»Æª
atof
atoi
atol
gcvt
strtod
strtol
strtoul
toascii
tolower
toupper
atof£¨½«×Ö·û´®×ª»»³É¸¡µãÐÍÊý£©
Ïà¹Øº¯Êý
atoi£¬atol£¬strtod£¬strtol£¬strtoul
±íÍ·Îļþ
#include <stdlib.h>
¶¨Ò庯Êý
double atof(const char *nptr);
º¯Êý˵Ã÷
atof()»áɨÃè²ÎÊýnptr×Ö·û´®£¬Ìø¹ýÇ°ÃæµÄ¿Õ¸ñ×Ö·û£¬Ö±µ½ÓöÉÏÊý×Ö»òÕý¸º·ûºÅ²Å¿ªÊ¼×öת»»£¬¶øÔÙÓöµ½·ÇÊý×Ö»ò×Ö·û´®½áÊøʱ('\0')²Å½áÊøת»»£¬²¢½«½á¹û·µ»Ø¡£²ÎÊýnptr×Ö·û´®¿É°üº¬Õý¸ººÅ¡¢Ð¡Êýµã»òE(e)À´±íʾָÊý²¿·Ö£¬Èç123.456»ò123e-2¡£
·µ»ØÖµ
·µ»Øת»»ºóµÄ¸¡µãÐÍÊý¡£
¸½¼Ó˵Ã÷
atof()ÓëʹÓÃstrtod(nptr,(char**)NULL)½á¹ûÏàͬ¡£
·¶Àý
/* ½«×Ö·û´®a Óë×Ö·û´®bת»»³ÉÊý×ÖºóÏà¼Ó*/
#include<stdlib.h>
main()
{
char *a=”-100.23”;
char *b=”200e-2”;
float c;
c=atof(a)+atof(b);
printf(“c=%.2f\n”,c);
}
Ö´ÐÐ
c=-98.23
¡¡
atoi£¨½«×Ö·û´®×ª»»³ÉÕûÐÍÊý£©
Ïà¹Øº¯Êý
atof£¬atol£¬atrtod£¬strtol£¬strtoul
±íÍ·Îļþ
#include<stdlib.h>
¶¨Ò庯Êý
int atoi(const char *nptr);
º¯Êý˵Ã÷
atoi()»áɨÃè²ÎÊýnptr×Ö·û´®£¬Ìø¹ýÇ°ÃæµÄ¿Õ¸ñ×Ö·û£¬Ö±µ½ÓöÉÏÊý×Ö»òÕý¸º·ûºÅ²Å¿ªÊ¼×öת»»£¬¶øÔÙÓöµ½·ÇÊý×Ö»ò×Ö·û´®½áÊøʱ('\0')²Å½áÊøת»»£¬²¢½«½á¹û·µ»Ø¡£
·µ»ØÖµ
·µ»Øת»»ºóµÄÕûÐÍÊý¡£
¸½¼Ó˵Ã÷
atoi()ÓëʹÓÃstrtol(nptr£¬(char**)NULL£¬10)£»½á¹ûÏàͬ¡£
·¶Àý
/* ½«×Ö·û´®a Óë×Ö·û´®bת»»³ÉÊý×ÖºóÏà¼Ó*/
#include<stdlib.h>
mian()
{
char a[]=”-100”;
char b[]=”456”;
int c;
c=atoi(a)+atoi(b);
printf(c=%d\n”,c);
}
Ö´ÐÐ
c=356
¡¡
atol£¨½«×Ö·û´®×ª»»³É³¤ÕûÐÍÊý£©
Ïà¹Øº¯Êý
atof£¬atoi£¬strtod£¬strtol£¬strtoul
±íÍ·Îļþ
#include<stdlib.h>
¶¨Ò庯Êý
long atol(const char *nptr);
º¯Êý˵Ã÷
atol()»áɨÃè²ÎÊýnptr×Ö·û´®£¬Ìø¹ýÇ°ÃæµÄ¿Õ¸ñ×Ö·û£¬Ö±µ½ÓöÉÏÊý×Ö»òÕý¸º·ûºÅ²Å¿ªÊ¼×öת»»£¬¶øÔÙÓöµ½·ÇÊý×Ö»ò×Ö·û´®½áÊøʱ('\0')²Å½áÊøת»»£¬²¢½«½á¹û·µ»Ø¡£
·µ»ØÖµ
·µ»Øת»»ºóµÄ³¤ÕûÐÍÊý¡£
¸½¼Ó˵Ã÷
atol()ÓëʹÓÃstrtol(nptr,(char**)NULL,10)£»½á¹ûÏàͬ¡£
·¶Àý
/*½«×Ö·û´®aÓë×Ö·û´®bת»»³ÉÊý×ÖºóÏà¼Ó*/
#include<stdlib.h>
main()
{
char a[]=”1000000000”;
char b[]=” 234
Ïà¹ØÎĵµ£º
»Ø¹Ë֮ǰµÄƪ·ù£¬CÓïÑÔµÄÖ÷Ì岿·Ö»ù±¾ÒѾ½éÉÜÍêÁË¡£Ö®ËùÒÔûÓнéÉÜC++µÄÏà¹ØÌØÐÔÊÇÒòΪÔÚ֮ǰµÄÎÄÕÂÖÐCºÍC++ÔÚÕâЩ·½Ã涼Óй²ÐÔ£¬ËùÒÔÔÚÃæÏò¶ÔÏó֮ǰ¡£ÎÒÃÇÏÈ°ÑÕâЩ¹²ÐÔ¸ø½éÉÜÍê¡£Ò²¾ÍÊÇ˵ÔÚ½éÉÜÃæÏò¶ÔÏó֮ǰ£¬ËùÓеÄÎÄÕ¶¼ÊÇCC++Öж¼ÄÜʹÓõġ£´ÓÕâµãÉÏÀ´¿´£¬ÏÖÔÚÕý¼«Á¦·Ü¶·ÓÚC++Õ½ÏßÉϵijõѧÕß»¹ÊǺÜÓÐÓô¦µÄ¡£
±¾Æª¼ÌÐ ......
1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ“a better C”£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“²»³¹µ×µØÃæÏò¶ÔÏ󔣩£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý¡£µ«ÊÇ£¬C++±Ï ......
The meaning of the c in calloc was vividly discussed in comp.lang.c in October 2000 (see here), with both clear (because, unlike malloc, calloc clears the memory it returns) and count (because, unlike malloc, calloc is passed a count of elements to allocate) suggested as possible explanations, howev ......
1¡¢C/C++³ÌÐòÔ±Çë×¢Ò⣬²»ÄÜÔÚcaseÓï¾ä²»Îª¿Õʱ“ÏòÏÂÖ´ÐД¡£
2¡¢ÖµÀàÐͺÍÒýÓÃÀàÐÍÖ®¼äµÄÇø±ð£ºC#µÄ»ù±¾ÀàÐÍ£¨int£¬charµÈ£©¶¼ÊÇÖµÀàÐÍ£¬ÊÇÔÚÕ»Öд´½¨µÄ¡£¶ø¶ÔÏóÊÇÒýÓÃÀàÐÍ£¬´´½¨ÓÚ¶ÑÖУ¬ÐèҪʹÓùؼü×Önew¡£
3¡¢ÔÚC#ÖÐͨ¹ýʵÀý·ÃÎʾ²Ì¬·½·¨»ò³ÉÔ±±äÁ¿ÊDz»ºÏ·¨µÄ£¬»áÉú³É±àÒëÆ÷´íÎó¡£µ«ÊÇÎÒÃÇ¿ÉÒÔͨ¹ýÉùÃ÷ËûÃÇ ......
¡¡1.¸ÅÊö
¡¡¡¡Ðí¶à³õѧÕ߶ÔC/C++ÓïÑÔÖеÄvoid¼°voidÖ¸ÕëÀàÐͲ»ÉõÀí½â£¬Òò´ËÔÚʹÓÃÉϳöÏÖÁËһЩ´íÎó¡£±¾ÎĽ«¶Ôvoid¹Ø¼ü×ÖµÄÉî¿Ìº¬Òå½øÐнâ˵£¬²¢ÏêÊövoid¼°voidÖ¸ÕëÀàÐ͵ÄʹÓ÷½·¨Óë¼¼ÇÉ¡£
¡¡¡¡2.voidµÄº¬Òå
¡¡¡¡voidµÄ×ÖÃæÒâ˼ÊÇ“ÎÞÀàÐÍ”£¬void *ÔòΪ“ÎÞÀàÐÍÖ¸Õ딣¬void *¿ÉÒÔÖ¸ÏòÈκÎÀàÐ͵ÄÊý¾ ......