프로그래밍/C 2010/05/24 23:57

C에서 StringTokenizer를 사용해서 문자열을 분리할 수 있다. 함수명은 strtok()...


#include <stdio.h>
#include <string.h>

int main() {
        char text[] = "N01 G00 X10.0 Y10.0";
        char splitter[] = " ";
        char *splitedText;

        // Split with the white spaces...
        splitedText = strtok(text, splitter);
        while (splitedText != NULL) {
            //Add your codes to precess the splitted string...
            printf("%s\n", splitedText);
            splitedText = strtok(NULL, splitter);
        }
}

저작자 표시 비영리 동일 조건 변경 허락

'프로그래밍 > C' 카테고리의 다른 글

strtok()  (0) 2010/05/24
posted by Elex
TAG ,

Trackback : http://www.elex.pe.kr/trackback/24 관련글 쓰기

댓글을 달아 주세요