char string library. There is a character string splitting function.

Committer:
tichise
Date:
Sun Apr 29 05:12:11 2018 +0000
Revision:
4:8f58c493d3fc
Parent:
2:dbd6f2a04946
fix header

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tichise 1:fc299d8c1c7e 1 #include "CharUtil.h"
tichise 0:c6bf0554e2f3 2 #include "mbed.h"
tichise 0:c6bf0554e2f3 3
tichise 0:c6bf0554e2f3 4 #define MAXITEM 20 // 数字が大きすぎるとメモリーオーバーエラーがでる
tichise 0:c6bf0554e2f3 5
tichise 1:fc299d8c1c7e 6 CharUtil::CharUtil() {
tichise 0:c6bf0554e2f3 7 }
tichise 0:c6bf0554e2f3 8
tichise 1:fc299d8c1c7e 9 int CharUtil::split(char *base, const char *delim, char *outlist[]){
tichise 2:dbd6f2a04946 10 char *tokenPointer;
tichise 0:c6bf0554e2f3 11 int cnt = 0;
tichise 0:c6bf0554e2f3 12
tichise 2:dbd6f2a04946 13 tokenPointer = strtok(base, delim);
tichise 0:c6bf0554e2f3 14
tichise 2:dbd6f2a04946 15 while(tokenPointer != NULL && cnt < MAXITEM) {
tichise 2:dbd6f2a04946 16 outlist[cnt++] = tokenPointer;
tichise 2:dbd6f2a04946 17 tokenPointer = strtok(NULL, delim);
tichise 0:c6bf0554e2f3 18 }
tichise 0:c6bf0554e2f3 19
tichise 0:c6bf0554e2f3 20 return cnt;
tichise 0:c6bf0554e2f3 21 }