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

CharUtil.cpp

Committer:
tichise
Date:
2018-04-29
Revision:
4:8f58c493d3fc
Parent:
2:dbd6f2a04946

File content as of revision 4:8f58c493d3fc:

#include "CharUtil.h"
#include "mbed.h"

#define MAXITEM 20 // 数字が大きすぎるとメモリーオーバーエラーがでる

CharUtil::CharUtil() {
}

int CharUtil::split(char *base, const char *delim, char *outlist[]){
    char *tokenPointer;
    int cnt = 0;

    tokenPointer = strtok(base, delim);

    while(tokenPointer != NULL && cnt < MAXITEM) {
        outlist[cnt++] = tokenPointer;
        tokenPointer = strtok(NULL, delim);
    }

    return cnt;
}