




已閱讀5頁,還剩13頁未讀, 繼續(xù)免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
標準c字符和字符串atof語法: #include double atof( const char *str );功能:將字符串str轉換成一個雙精度數(shù)值并返回結果。 參數(shù)str 必須以有效數(shù)字開頭,但是允許以“E”或“e”除外的任意非數(shù)字字符結尾。例如: x = atof( 42.0is_the_answer );x的值為42.0.相關主題:atoi() and atol().atoi語法: #include int atoi( const char *str );功能:將字符串str轉換成一個整數(shù)并返回結果。參數(shù)str 以數(shù)字開頭,當函數(shù)從str 中讀到非數(shù)字字符則結束轉換并將結果返回。例如, i = atoi( 512.035 );i 的值為 512.相關主題:atof() and atol().atol語法: #include long atol( const char *str );功能:將字符串轉換成長整型數(shù)并返回結果。函數(shù)會掃描參數(shù)str字符串,跳過前面的空格字符,直到遇上數(shù)字或正負符號才開始做轉換,而再遇到非數(shù)字或字符串結束時才結束轉換,并將結果返回。例如, x = atol( 1024.0001 );x的值為1024L.相關主題: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 );相關主題: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 );相關主題:isalnum(), iscntrl(), isdigit(), isgraph(), isprint(), ispunct(), and isspace().iscntrl語法: #include int iscntrl( int ch );功能:如果參數(shù)是控制字符(0和0x1F之間的字符,或者等于0x7F)函數(shù)返回非零值,否則返回零值。 相關主題: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 );相關主題:isalnum(), isalpha(), iscntrl(), isgraph(), isprint(), ispunct(), and isspace().isgraph語法: #include int isgraph( int ch );功能:如果參數(shù)是除空格外的可打印字符(可見的字符),函數(shù)返回非零值,否則返回零值。相關主題:isalnum(), isalpha(), iscntrl(), isdigit(), isprint(), ispunct(), and isspace().islower語法: #include int islower( int ch );功能:如果參數(shù)是小寫字母字符,函數(shù)返回非零值,否則返回零值。相關主題:isupper()isprint語法: #include int isprint( int ch );功能:如果參數(shù)是可打印字符(包括空格),函數(shù)返回非零值,否則返回零值。相關主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), ispunct(), and isspace().ispunct語法: #include int ispunct( int ch );功能:如果參數(shù)是除字母,數(shù)字和空格外可打印字符,函數(shù)返回非零值,否則返回零值。相關主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), isprint(), and isspace().isspace語法: #include int isspace( int ch );功能:如果參數(shù)是空格類字符(即:單空格,制表符,垂直制表符,滿頁符,回車符,新行符),函數(shù)返回非零值,否則返回零值。相關主題:isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(), and ispunct().isupper語法: #include int isupper( int ch );功能:如果參數(shù)是大寫字母字符,函數(shù)返回非零值,否則返回零值。相關主題:tolower()isxdigit語法: #include int isxdigit( int ch );功能:如果參數(shù)是十六進制數(shù)字字符(即:A-F, a-f, 0-9),函數(shù)返回非零值,否則返回零值。相關主題: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 );相關主題: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 相關主題:memchr(), memcpy(), and strcmp().memcpy語法: #include void *memcpy( void *to, const void *from, size_t count );功能:函數(shù)從from中復制count 個字符到to中,并返回to指針。 如果to 和 from 重疊,則函數(shù)行為不確定。相關主題:memmove().memmove語法: #include void *memmove( void *to, const void *from, size_t count );功能: 與mencpy相同,不同的是當to 和 from 重疊,函數(shù)正常仍能工作。相關主題:memcpy().memset語法: #include void *memset( void *buffer, int ch, size_t count );功能: 函數(shù)拷貝ch 到buffer 從頭開始的count 個字符里, 并返回buffer指針。 memset() 可以應用在將一段內存初始化為某個值。例如: memset( the_array, 0, sizeof(the_array) );這是將一個數(shù)組的所以分量設置成零的很便捷的方法。相關主題: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 );相關主題:strchr(), strcmp(), and strcpy().strchr語法: #include char *strchr( const char *str, int ch );功能:函數(shù)返回一個指向str 中ch 首次出現(xiàn)的位置,當沒有在str 中找ch到返回NULL。相關主題: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 );相關主題:memcmp(), strchr(), strcpy(), and strncmp().strcoll語法: #include int strcoll( const char *str1, const char *str2 );功能:比較字符串str1 和 str2, 很象strcmp. 但是, strcoll() 使用在目前環(huán)境中由setlocale()設定的次序進行比較。strcpy語法: #include char *strcpy( char *to, const char *from );功能:復制字符串from 中的字符到字符串to,包括空值結束符。返回值為指針to。相關主題:memcpy(), strchr(), strcmp(), strncmp(), and strncpy().strcspn語法: #include size_t strcspn( const char *str1, const char *str2 );功能:函數(shù)返回str1 開頭連續(xù)n個字符都不含字符串str2內字符的字符數(shù)。相關主題:strrchr(), strpbrk(), strstr(), and strtok().strerror語法: #include char *strerror( int num );功能:函數(shù)返回一個被定義的與某錯誤代碼相關的錯誤信息。strlen語法: #include size_t strlen( char *str );功能:函數(shù)返回字符串str 的長度( 即空值結束符之前字符數(shù)目)。相關主題:memcpy(), strchr(), strcmp(), and strncmp().strncat語法: #include char *strncat( char *str1, const char *str2, size_t count );功能:將字符串from 中至多count個字符連接到字符串to中,追加空值結束符。返回處理完成的字符串。相關主題: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, 那么當比較到第一個空值結束符時,就結束處理。相關主題:strcmp(), strnchr(), and strncpy().strncpy語法: #include char *strncpy( char *to, const char *from, size_t count );功能:將字符串from 中至多count個字符復制到字符串to中。如果字符串from 的長度小于count,其余部分用0填補。返回處理完成的字符串。相關主題:memcpy(), strchr(), strncat(), and strncmp().strpbrk語法: #include char *strpbrk( const char *str1, const char *str2 );功能:函數(shù)返回一個指針,它指向字符串str2中任意字符在字符串str1 首次出現(xiàn)的位置,如果不存在返回NULL。相關主題:strspn(), strrchr(), strstr(), and strtok().strrchr語法: #include char *strrchr( const char *str, int ch );功能:函數(shù)返回一個指針,它指向字符ch 在字符串str末次出現(xiàn)的位置,如果匹配失敗,返回NULL。相關主題:strpbrk(), strspn(), strstr(), strtok(),strspn語法: #include size_t strspn( const char *str1, const char *str2 );功能:函數(shù)返回字符串str1中第一個不包含于字符串str2的字符的索引。相關主題:strpbrk(), strrchr(), strstr(), strtok(),strstr語法: #include char *strstr( const char *str1, const char *str2 );功能:函數(shù)返回一個指針,它指向字符串str2 首次出現(xiàn)于字符串str1中的位置,如果沒有找到,返回NULL。相關主題:strchr(), strcspn(), strpbrk(), strspn(), strtok(), strrchr(),strtod語法: #include double strtod( const char *start, char *end );功能:函數(shù)返回帶符號的字符串start所表示的浮點型數(shù)。字符串end 指向所表示的浮點型數(shù)之后的部分。如果溢出發(fā)生,返回HUGE_VAL或 -HUGE_VAL。相關主題:atof()strtok語法: #include char *strtok( char *str1, const char *str2 );功能:函數(shù)返回字符串str1中緊接“標記”的部分的指針, 字符串str2是作為標記的分隔符。如果分隔標記沒有找到,函數(shù)返回NULL。為了將字符串轉換成標記,第一次調用str1 指向作為標記的分隔符。之后所以的調用str1 都應為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 ); 以上代碼的運行結果是: 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)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 江蘇南京金陵中學2024~2025學年高二下冊期末考試數(shù)學試題學生卷
- 江蘇常州聯(lián)盟學校2024~2025學年高一下冊期末調研數(shù)學試題學生卷
- 農村居民消費升級對農村金融服務的需求變化考核試卷
- 創(chuàng)新思維培訓效果評估考核試卷
- 設備自動化升級方案考核試卷
- 健康促進項目評估中的慢性病預防與控制效果評價考核試卷
- 水資源保護法規(guī)考核試卷
- 壓力傳感器數(shù)據(jù)傳輸考核試卷
- 哺乳期營養(yǎng)保健品效果評價考核試卷
- 智能化醫(yī)療器械產品追溯系統(tǒng)考核試卷
- 江蘇省南京市六校聯(lián)合體2024-2025學年高一下學期期末調研測試歷史試題(含答案)
- 2025年法律職業(yè)資格考試民法專項練習卷:合同法真題解析及試題
- 玻尿酸介紹課件
- 2025中國心肌病綜合管理指南要點解讀課件
- 技術中心人員管理制度
- 2025年形勢與政策課程期末考試復習試卷及答案
- 財產獨立性專項審計報告模板3(清算審計報告模板)
- 2025年中考英語答題技巧與模式專題11閱讀七選五(學生版+解析)
- 高一生物遺傳測試卷及答案
- 衡水一中高一試卷及答案
- 2025-2030中國MEMS設計服務行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
評論
0/150
提交評論