W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
原型:extern char *strtok(char *s, char *delim);
用法:#include <string.h>
功能:分解字符串為一組標記串。s為要分解的字符串,delim為分隔符字符串。
說明:首次調(diào)用時,s必須指向要分解的字符串,隨后調(diào)用要把s設(shè)成NULL。
strtok在s中查找包含在delim中的字符并用NULL('\0')來替換,直到找遍整個字符串。
返回指向下一個標記串。當沒有標記串時則返回空字符NULL。
舉例:
// strtok.c
#include <syslib.h>
#include <string.h>
#include <stdio.h>
main()
{
char *s="Golden Global View";
char *d=" ";
char *p;
clrscr();
p=strtok(s,d);
while(p)
{
printf("%s\n",s);
strtok(NULL,d);
}
getchar();
return 0;
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: