|
h>htNLinuxÁªÃË
|
¶¨Ò庯Êý | double strtod(const char *nptr,char **endptr);htNLinuxÁªÃË
|
º¯Êý˵Ã÷ | strtod()»áɨÃè²ÎÊýnptr×Ö·û´®£¬Ìø¹ýÇ°ÃæµÄ¿Õ¸ñ×Ö·û£¬Ö±µ½ÓöÉÏÊý×Ö»òÕý¸º·ûºÅ²Å¿ªÊ¼×öת»»£¬µ½³öÏÖ·ÇÊý×Ö»ò×Ö·û´®½áÊøÊ±(' ')²Å½áÊø×ª»»£¬²¢½«½á¹û·µ»Ø¡£Èôendptr²»ÎªNULL£¬Ôò»á½«Óöµ½²»ºÏÌõ¼þ¶øÖÕÖ¹µÄnptrÖеÄ×Ö·ûÖ¸ÕëÓÉendptr´«»Ø¡£²ÎÊýnptr×Ö·û´®¿É°üº¬Õý¸ººÅ¡¢Ð¡Êýµã»òE(e)À´±íʾָÊý²¿·Ö¡£Èç123.456»ò123e-2¡£htNLinuxÁªÃË
|
·µ»ØÖµ | ·µ»Ø×ª»»ºóµÄ¸¡µãÐÍÊý¡£htNLinuxÁªÃË
|
¸½¼Ó˵Ã÷ | ²Î¿¼atof()¡£htNLinuxÁªÃË
|
·¶Àý | /*½«×Ö·û´®a£¬b£¬c ·Ö±ð²ÉÓÃ10£¬2£¬16 ½øÖÆ×ª»»³ÉÊý×Ö*/htNLinuxÁªÃË #include<stdlib.h>htNLinuxÁªÃË mian()htNLinuxÁªÃË {htNLinuxÁªÃË char a[]=¡±1000000000¡±;htNLinuxÁªÃË char b[]=¡±1000000000¡±;htNLinuxÁªÃË char c[]=¡±ffff¡±;htNLinuxÁªÃË printf(¡°a=%dn¡±,strtod(a,NULL,10));htNLinuxÁªÃË printf(¡°b=%dn¡±,strtod(b,NULL,2));htNLinuxÁªÃË printf(¡°c=%dn¡±,strtod(c,NULL,16));htNLinuxÁªÃË }htNLinuxÁªÃË
|
Ö´ÐÐ | a=1000000000htNLinuxÁªÃË b=512htNLinuxÁªÃË c=65535htNLinuxÁªÃË
|
| ¡¡ |
htNLinuxÁªÃË
| htNLinuxÁªÃË strtol£¨½«×Ö·û´®×ª»»³É³¤ÕûÐÍÊý£© |
Ïà¹Øº¯Êý | atof£¬atoi£¬atol£¬strtod£¬strtoulhtNLinuxÁªÃË
|
±íÍ·Îļþ | #include<stdlib.h>htNLinuxÁªÃË
|
¶¨Ò庯Êý | long int strtol(const char *nptr,char **endptr,int base);htNLinuxÁªÃË
|
º¯Êý˵Ã÷ | strtol()»á½«²ÎÊýnptr×Ö·û´®¸ù¾Ý²ÎÊýbaseÀ´×ª»»³É³¤ÕûÐÍÊý¡£²ÎÊýbase·¶Î§´Ó2ÖÁ36£¬»ò0¡£²ÎÊýbase´ú±í²ÉÓõĽøÖÆ·½Ê½£¬ÈçbaseֵΪ10Ôò²ÉÓÃ10½øÖÆ£¬ÈôbaseֵΪ16Ôò²ÉÓÃ16½øÖƵȡ£µ±baseֵΪ0ʱÔòÊDzÉÓÃ10½øÖÆ×öת»»£¬µ«Óöµ½Èç'0x'ǰÖÃ×Ö·ûÔò»áʹÓÃ16½øÖÆ×öת»»¡£Ò»¿ªÊ¼strtol()»áɨÃè²ÎÊýnptr×Ö·û´®£¬Ìø¹ýÇ°ÃæµÄ¿Õ¸ñ×Ö·û£¬Ö±µ½ÓöÉÏÊý×Ö»òÕý¸º·ûºÅ²Å¿ªÊ¼×öת»»£¬ÔÙÓöµ½·ÇÊý×Ö»ò×Ö·û´®½áÊøÊ±(' ')½áÊø×ª»»£¬²¢½«½á¹û·µ»Ø¡£Èô²ÎÊýendptr²»ÎªNULL£¬Ôò»á½«Óöµ½²»ºÏÌõ¼þ¶øÖÕÖ¹µÄnptrÖеÄ×Ö·ûÖ¸ÕëÓÉendptr·µ»Ø¡£htNLinuxÁªÃË
|
·µ»ØÖµ | ·µ»Ø×ª»»ºóµÄ³¤ÕûÐÍÊý£¬·ñÔò·µ»ØERANGE²¢½«´íÎó´úÂë´æÈëerrnoÖС£htNLinuxÁªÃË
|
¸½¼Ó˵Ã÷ | ERANGEÖ¸¶¨µÄת»»×Ö·û´®³¬³öºÏ·¨·¶Î§¡£htNLinuxÁªÃË
|
·¶Àý | /* ½«×Ö·û´®a£¬b£¬c ·Ö±ð²ÉÓÃ10£¬2£¬16½øÖÆ×ª»»³ÉÊý×Ö*/htNLinuxÁªÃË #include<stdlib.h>htNLinuxÁªÃË main()htNLinuxÁªÃË {htNLinuxÁªÃË char a[]=¡±1000000000¡±;htNLinuxÁªÃË char b[]=¡±1000000000¡±;htNLinuxÁªÃË char c[]=¡±ffff¡±;htNLinuxÁªÃË printf(¡°a=%dn¡±,strtol(a,NULL,10));htNLinuxÁªÃË printf(¡°b=%dn¡±,strtol(b,NULL,2));htNLinuxÁªÃË printf(¡°c=%dn¡±,strtol(c,NULL,16));htNLinuxÁªÃË }htNLinuxÁªÃË
|
Ö´ÐÐ | a=1000000000htNLinuxÁªÃË b=512htNLinuxÁªÃË c=65535htNLinuxÁªÃË
|
| ¡¡ |
htNLinuxÁªÃË
| htNLinuxÁªÃË strtoul£¨½«×Ö·û´®×ª»»³ÉÎÞ·ûºÅ³¤ÕûÐÍÊý£© |
Ïà¹Øº¯Êý | atof£¬atoi£¬atol£¬strtod£¬strtolhtNLinuxÁªÃË
|
±íÍ·Îļþ | #include<stdlib.h>htNLinuxÁªÃË
|
¶¨Ò庯Êý | unsigned long int strtoul(const char *nptr,char **endptr,int base);htNLinuxÁªÃË
|
º¯Êý˵Ã÷ | strtoul()»á½«²ÎÊýnptr×Ö·û´®¸ù¾Ý²ÎÊýbaseÀ´×ª»»³ÉÎÞ·ûºÅµÄ³¤ÕûÐÍÊý¡£²ÎÊýbase·¶Î§´Ó2ÖÁ36£¬»ò0¡£²ÎÊýbase´ú±í²ÉÓõĽøÖÆ·½Ê½£¬ÈçbaseֵΪ10Ôò²ÉÓÃ10½øÖÆ£¬ÈôbaseֵΪ16Ôò²ÉÓÃ16½øÖÆÊýµÈ¡£µ±baseֵΪ0ʱÔòÊDzÉÓÃ10½øÖÆ×öת»»£¬µ«Óöµ½Èç'0x'ǰÖÃ×Ö·ûÔò»áʹÓÃ16½øÖÆ×öת»»¡£Ò»¿ªÊ¼strtoul()»áɨÃè²ÎÊýnptr×Ö·û´®£¬Ìø¹ýÇ°ÃæµÄ¿Õ¸ñ×Ö·û´®£¬Ö±µ½ÓöÉÏÊý×Ö»òÕý¸º·ûºÅ²Å¿ªÊ¼×öת»»£¬ÔÙÓöµ½·ÇÊý×Ö»ò×Ö·û´®½áÊøÊ±(' ')½áÊø×ª»»£¬²¢½«½á¹û·µ»Ø¡£Èô²ÎÊýendptr²»ÎªNULL£¬Ôò»á½«Óöµ½²»ºÏÌõ¼þ¶øÖÕÖ¹µÄnptrÖеÄ×Ö·ûÖ¸ÕëÓÉendptr·µ»Ø¡£htNLinuxÁªÃË
|
·µ»ØÖµ | ·µ»Ø×ª»»ºóµÄ³¤ÕûÐÍÊý£¬·ñÔò·µ»ØERANGE²¢½«´íÎó´úÂë´æÈëerrnoÖС£htNLinuxÁªÃË
|
¸½¼Ó˵Ã÷ | ERANGEÖ¸¶¨µÄת»»×Ö·û´®³¬³öºÏ·¨·¶Î§¡£htNLinuxÁªÃË
|
·¶Àý | ²Î¿¼strtol()htNLinuxÁªÃË
|
| ¡¡ |
htNLinuxÁªÃË
| htNLinuxÁªÃË toascii£¨½«ÕûÐÍÊýת»»³ÉºÏ·¨µÄASCII Âë×Ö·û£© |
Ïà¹Øº¯Êý | isascii£¬toupper£¬tolowerhtNLinuxÁªÃË
|
±íÍ·Îļþ | #include<ctype.h>htNLinuxÁªÃË
|
¶¨Ò庯Êý | int toascii(int c)htNLinuxÁªÃË
|
º¯Êý˵Ã÷ | toascii()»á½«²ÎÊýcת»»³É7λµÄunsigned charÖµ£¬µÚ°ËλÔò»á±»Çå³ý£¬´Ë×Ö·û¼´»á±»×ª³ÉASCIIÂë×Ö·û¡£htNLinuxÁªÃË
|
·µ»ØÖµ | ½«×ª»»³É¹¦µÄASCIIÂë×Ö·ûÖµ·µ»Ø¡£htNLinuxÁªÃË
|
·¶Àý | #include<stdlib.h>htNLinuxÁªÃË main()htNLinuxÁªÃË {htNLinuxÁªÃË int a=217;htNLinuxÁªÃË char b;htNLinuxÁªÃË printf(¡°before toascii () : a value =%d(%c)n¡±,a,a);htNLinuxÁªÃË b=toascii(a);htNLinuxÁªÃË printf(¡°after toascii() : a value =%d(%c)n¡±,b,b);htNLinuxÁªÃË }htNLinuxÁªÃË
|
Ö´ÐÐ | before toascii() : a value =217()htNLinuxÁªÃË after toascii() : a value =89(Y)htNLinuxÁªÃË
|
| ¡¡ |
htNLinuxÁªÃË
| htNLinuxÁªÃË tolower£¨½«´óд×Öĸת»»³ÉСд×Öĸ£© |
Ïà¹Øº¯Êý | isalpha£¬toupperhtNLinuxÁªÃË
|
±íÍ·Îļþ | #include<stdlib.h>htNLinuxÁªÃË
|
¶¨Ò庯Êý | int tolower(int c);htNLinuxÁªÃË
|
º¯Êý˵Ã÷ | Èô²ÎÊýcΪ´óд×ÖĸÔò½«¸Ã¶ÔÓ¦µÄСд×Öĸ·µ»Ø¡
LinuxÁªÃËÊÕ¼¯ÕûÀí ,תÌùÇë±êÃ÷ÔʼÁ´½Ó,ÈçÓÐÈκÎÒÉÎÊ»¶ÓÀ´±¾Õ¾LinuxÂÛ̳ÌÖÂÛ |
|
|
|
|