C语言库函数的实战之一
生活随笔
收集整理的這篇文章主要介紹了
C语言库函数的实战之一
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
//-1:strtok()函數(shù)
#include<stdio.h>
#include<string.h>int main(void)
{char buf[]="hello#world#today";//即將被分割的字符串char *temp = strtok(buf,"#");while(temp){printf("%s ",temp);temp = strtok(NULL,"#");}printf("\n");
return 0;}
//-2:strrchr() #include <string.h> #include <stdio.h> void main() {char * pCh = "www.inkcool.com";char * pFind = strrchr(pCh, '.');//找出點(diǎn).最后一次出現(xiàn)在pCH的位置if ( pFind != NULL){printf("%s", pFind); //可以直接printf(pFind);printf("/n");左邊的表達(dá)式是合二為一的表達(dá)方法;}printf("\n"); }
//-3:strpbrk():返回兩個(gè)字符串中首個(gè)相同字符的位置 #include<stdio.h> #include<string.h> int main(void){char* s1 = "http://see.xidian.edu.cn/cpp/u/xitong/";//在C語(yǔ)言中,用指針形式來(lái)定義未知長(zhǎng)度的字符串char* s2 = "see";char* p = strpbrk(s1,s2);if(p){printf("The result is: %s\n",p); }else{ //-4:strlen()返回字符串的長(zhǎng)度 #include<stdio.h> #include<string.h>int main(void) {char* str1 = "zheng chaobing";printf("strlen(str1)=%d",strlen(str1));return 0;}
printf("Sorry!\n"); } return 0; }
轉(zhuǎn)載于:https://www.cnblogs.com/ZZiz/p/7622212.html
總結(jié)
以上是生活随笔為你收集整理的C语言库函数的实战之一的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Apache Kafka:大数据的实时处
- 下一篇: 查看HTTP请求返回状态码对照表详解