




已閱讀5頁,還剩13頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
標(biāo)準(zhǔn)c字符和字符串a(chǎn)tof語法: #include double atof( const char *str );功能:將字符串str轉(zhuǎn)換成一個雙精度數(shù)值并返回結(jié)果。 參數(shù)str 必須以有效數(shù)字開頭,但是允許以“E”或“e”除外的任意非數(shù)字字符結(jié)尾。例如: x = atof( 42.0is_the_answer );x的值為42.0.相關(guān)主題:atoi() and atol().atoi語法: #include int atoi( const char *str );功能:將字符串str轉(zhuǎn)換成一個整數(shù)并返回結(jié)果。參數(shù)str 以數(shù)字開頭,當(dāng)函數(shù)從str 中讀到非數(shù)字字符則結(jié)束轉(zhuǎn)換并將結(jié)果返回。例如, i = atoi( 512.035 );i 的值為 512.相關(guān)主題:atof() and atol().atol語法: #include long atol( const char *str );功能:將字符串轉(zhuǎn)換成長整型數(shù)并返回結(jié)果。函數(shù)會掃描參數(shù)str字符串,跳過前面的空格字符,直到遇上數(shù)字或正負(fù)符號才開始做轉(zhuǎn)換,而再遇到非數(shù)字或字符串結(jié)束時才結(jié)束轉(zhuǎn)換,并將結(jié)果返回。例如, x = atol( 1024.0001 );x的值為1024L.相關(guān)主題:atof() and atoi().isalnum語法: #include int isalnum( int ch );功能:如果參數(shù)是數(shù)字或字母字符,函數(shù)返回非零值,否則返回零值。 char c; scanf( %c, &c ); if( isalnum(c) ) printf( You entered the alphanumeric character %cn, c );相關(guān)主題:isalpha(), iscntrl(), isdigit(), isgraph(), isprint(), ispunct(), and isspace().isalpha語法: #include int isalpha( int ch );功能:如果參數(shù)是字母字符,函數(shù)返回非零值,否則返回零值。 char c; scanf( %c, &c ); if( isalpha(c) ) printf( You entered a letter of the alphabetn );相關(guān)主題:isalnum(), iscntrl(), isdigit(), isgraph(), isprint(), ispunct(), and isspace().iscntrl語法: #include int iscntrl( int ch );功能:如果參數(shù)是控制字符(0和0x1F之間的字符,或者等于0x7F)函數(shù)返回非零值,否則返回零值。 相關(guān)主題:isalnum(), isalpha(), isdigit(), isgraph(), isprint(), ispunct(), and isspace().isdigit語法: #include int isdigit( int ch );功能:如果參數(shù)是0到9之間的數(shù)字字符,函數(shù)返回非零值,否則返回零值. char c; scanf( %c, &c ); if( isdigit(c) ) printf( You entered the digit %cn, c );相關(guān)主題:isalnum(), isalpha(), iscntrl(), isgraph(), isprint(), ispunct(), and isspace().isgraph語法: #include int isgraph( int ch );功能:如果參數(shù)是除空格外的可打印字符(可見的字符),函數(shù)返回非零值,否則返回零值。相關(guān)主題:isalnum(), isalpha(), iscntrl(), isdigit(), isprint(), ispunct(), and isspace().islower語法: #include int islower( int ch );功能:如果參數(shù)是小寫字母字符,函數(shù)返回非零值,否則返回零值。相關(guān)主題:isupper()isprint語法: #include int isprint( int ch );功能:如果參數(shù)是可打印字符(包括空格),函數(shù)返回非零值,否則返回零值。相關(guān)主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), ispunct(), and isspace().ispunct語法: #include int ispunct( int ch );功能:如果參數(shù)是除字母,數(shù)字和空格外可打印字符,函數(shù)返回非零值,否則返回零值。相關(guān)主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), isprint(), and isspace().isspace語法: #include int isspace( int ch );功能:如果參數(shù)是空格類字符(即:單空格,制表符,垂直制表符,滿頁符,回車符,新行符),函數(shù)返回非零值,否則返回零值。相關(guān)主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), and ispunct().isupper語法: #include int isupper( int ch );功能:如果參數(shù)是大寫字母字符,函數(shù)返回非零值,否則返回零值。相關(guān)主題:tolower()isxdigit語法: #include int isxdigit( int ch );功能:如果參數(shù)是十六進(jìn)制數(shù)字字符(即:A-F, a-f, 0-9),函數(shù)返回非零值,否則返回零值。相關(guān)主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), ispunct(), and isspace().memchr語法: #include void *memchr( const void *buffer, int ch, size_t count );功能:函數(shù)在buffer指向的數(shù)組的count個字符的字符串里查找ch 首次出現(xiàn)的位置。返回一個指針,指向ch 在字符串中首次出現(xiàn)的位置, 如果ch 沒有在字符串中找到,返回NULL。例如: char names = Alan Bob Chris X Dave; if( memchr(names,X,strlen(names) = NULL ) printf( Didnt find an Xn ); else printf( Found an Xn );相關(guān)主題:memcpy() and strstr().memcmp語法: #include int memcmp( const void *buffer1, const void *buffer2, size_t count );功能:函數(shù)比較buffer1 和 buffer2的前count 個字符。返回值如下:Value 解釋 less than 0 buffer1 is less than buffer2 equal to 0 buffer1 is equal to buffer2 greater than 0 buffer1 is greater than buffer2 相關(guān)主題:memchr(), memcpy(), and strcmp().memcpy語法: #include void *memcpy( void *to, const void *from, size_t count );功能:函數(shù)從from中復(fù)制count 個字符到to中,并返回to指針。 如果to 和 from 重疊,則函數(shù)行為不確定。相關(guān)主題:memmove().memmove語法: #include void *memmove( void *to, const void *from, size_t count );功能: 與mencpy相同,不同的是當(dāng)to 和 from 重疊,函數(shù)正常仍能工作。相關(guān)主題:memcpy().memset語法: #include void *memset( void *buffer, int ch, size_t count );功能: 函數(shù)拷貝ch 到buffer 從頭開始的count 個字符里, 并返回buffer指針。 memset() 可以應(yīng)用在將一段內(nèi)存初始化為某個值。例如: memset( the_array, 0, sizeof(the_array) );這是將一個數(shù)組的所以分量設(shè)置成零的很便捷的方法。相關(guān)主題:memcmp(), memcpy(), and memmove().strcat語法: #include char *strcat( char *str1, const char *str2 );功能:函數(shù)將字符串str2 連接到str1的末端,并返回指針str1. 例如: printf( Enter your name: ); scanf( %s, name ); title = strcat( name, the Great ); printf( Hello, %sn, title );相關(guān)主題:strchr(), strcmp(), and strcpy().strchr語法: #include char *strchr( const char *str, int ch );功能:函數(shù)返回一個指向str 中ch 首次出現(xiàn)的位置,當(dāng)沒有在str 中找ch到返回NULL。相關(guān)主題:strpbrk(), strspn(), strstr(), and strtok().strcmp語法: #include int strcmp( const char *str1, const char *str2 );功能:比較字符串str1 and str2, 返回值如下:返回值 解釋 less than 0 str1 is less than str2 equal to 0 str1 is equal to str2 greater than 0 str1 is greater than str2 例如: printf( Enter your name: ); scanf( %s, name ); if( strcmp( name, Mary ) = 0 ) printf( Hello, Dr. Mary!n );相關(guān)主題:memcmp(), strchr(), strcpy(), and strncmp().strcoll語法: #include int strcoll( const char *str1, const char *str2 );功能:比較字符串str1 和 str2, 很象strcmp. 但是, strcoll() 使用在目前環(huán)境中由setlocale()設(shè)定的次序進(jìn)行比較。strcpy語法: #include char *strcpy( char *to, const char *from );功能:復(fù)制字符串from 中的字符到字符串to,包括空值結(jié)束符。返回值為指針to。相關(guān)主題:memcpy(), strchr(), strcmp(), strncmp(), and strncpy().strcspn語法: #include size_t strcspn( const char *str1, const char *str2 );功能:函數(shù)返回str1 開頭連續(xù)n個字符都不含字符串str2內(nèi)字符的字符數(shù)。相關(guān)主題:strrchr(), strpbrk(), strstr(), and strtok().strerror語法: #include char *strerror( int num );功能:函數(shù)返回一個被定義的與某錯誤代碼相關(guān)的錯誤信息。strlen語法: #include size_t strlen( char *str );功能:函數(shù)返回字符串str 的長度( 即空值結(jié)束符之前字符數(shù)目)。相關(guān)主題:memcpy(), strchr(), strcmp(), and strncmp().strncat語法: #include char *strncat( char *str1, const char *str2, size_t count );功能:將字符串from 中至多count個字符連接到字符串to中,追加空值結(jié)束符。返回處理完成的字符串。相關(guān)主題:strcat(), strnchr(), strncmp(), and strncpy().strncmp語法: #include int strncmp( const char *str1, const char *str2, size_t count );功能:比較字符串str1 和 str2中至多count個字符。返回值如下:返回值 解釋 less than 0 str1 is less than str2 equal to 0 str1 is equal to str2 greater than 0 str1 is greater than str2 如果參數(shù)中任一字符串長度小于count, 那么當(dāng)比較到第一個空值結(jié)束符時,就結(jié)束處理。相關(guān)主題:strcmp(), strnchr(), and strncpy().strncpy語法: #include char *strncpy( char *to, const char *from, size_t count );功能:將字符串from 中至多count個字符復(fù)制到字符串to中。如果字符串from 的長度小于count,其余部分用0填補(bǔ)。返回處理完成的字符串。相關(guān)主題:memcpy(), strchr(), strncat(), and strncmp().strpbrk語法: #include char *strpbrk( const char *str1, const char *str2 );功能:函數(shù)返回一個指針,它指向字符串str2中任意字符在字符串str1 首次出現(xiàn)的位置,如果不存在返回NULL。相關(guān)主題:strspn(), strrchr(), strstr(), and strtok().strrchr語法: #include char *strrchr( const char *str, int ch );功能:函數(shù)返回一個指針,它指向字符ch 在字符串str末次出現(xiàn)的位置,如果匹配失敗,返回NULL。相關(guān)主題:strpbrk(), strspn(), strstr(), strtok(),strspn語法: #include size_t strspn( const char *str1, const char *str2 );功能:函數(shù)返回字符串str1中第一個不包含于字符串str2的字符的索引。相關(guān)主題:strpbrk(), strrchr(), strstr(), strtok(),strstr語法: #include char *strstr( const char *str1, const char *str2 );功能:函數(shù)返回一個指針,它指向字符串str2 首次出現(xiàn)于字符串str1中的位置,如果沒有找到,返回NULL。相關(guān)主題:strchr(), strcspn(), strpbrk(), strspn(), strtok(), strrchr(),strtod語法: #include double strtod( const char *start, char *end );功能:函數(shù)返回帶符號的字符串start所表示的浮點(diǎn)型數(shù)。字符串end 指向所表示的浮點(diǎn)型數(shù)之后的部分。如果溢出發(fā)生,返回HUGE_VAL或 -HUGE_VAL。相關(guān)主題:atof()strtok語法: #include char *strtok( char *str1, const char *str2 );功能:函數(shù)返回字符串str1中緊接“標(biāo)記”的部分的指針, 字符串str2是作為標(biāo)記的分隔符。如果分隔標(biāo)記沒有找到,函數(shù)返回NULL。為了將字符串轉(zhuǎn)換成標(biāo)記,第一次調(diào)用str1 指向作為標(biāo)記的分隔符。之后所以的調(diào)用str1 都應(yīng)為NULL。例如: char str = now # is the time for all # good men to come to the # aid of their country; char delims = #; char *result = NULL; result = strtok( str, delims ); while( result != NULL ) printf( result is %sn, result );result = strtok( NULL, delims ); 以上代碼的運(yùn)行結(jié)果是: result is now result is is the time for all result is good men
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 安徽省阜陽市潁州區(qū)2025屆數(shù)學(xué)三年級第一學(xué)期期末質(zhì)量跟蹤監(jiān)視模擬試題含解析
- 2025屆西藏山南地區(qū)扎囊縣數(shù)學(xué)三年級第一學(xué)期期末模擬試題含解析
- 行政管理的公共關(guān)系學(xué)備考試題及答案
- 2022 年中級會計(jì)師考試《中級經(jīng)濟(jì)法》真題及解析(9月5日)
- 劇組協(xié)調(diào)員助理場記聘用合同
- 長期公寓租賃合同
- 中級經(jīng)濟(jì)師考試對行業(yè)發(fā)展的影響與試題及答案
- 農(nóng)民信息技術(shù)應(yīng)用服務(wù)合同
- 知識產(chǎn)權(quán)轉(zhuǎn)讓與保密協(xié)議細(xì)節(jié)展開說明文檔
- 心理學(xué)應(yīng)用知識練習(xí)題
- 法律法規(guī)合規(guī)性評價記錄表
- 初中歷史資本主義制度的初步確立 作業(yè)設(shè)計(jì)
- 能源英語面面觀 知到智慧樹網(wǎng)課答案
- 電腦時代需要練字辯論材料
- MOOC 職業(yè)生涯開發(fā)與管理-南京郵電大學(xué) 中國大學(xué)慕課答案
- 中國書法藝術(shù)智慧樹知到期末考試答案2024年
- 2024年4月自考00015英語(二)試題
- 上汽大眾電子說明書
- 數(shù)學(xué)建模與系統(tǒng)仿真智慧樹知到期末考試答案2024年
- 足球鞋推廣方案
- 論三農(nóng)工作培訓(xùn)課件
評論
0/150
提交評論