comparison c/regexParser/word.c @ 115:ca30f8334741 pairPro

rename createRegexParser.cc to regexParser.cc
author Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
date Tue, 24 Nov 2015 14:38:26 +0900
parents c/getWord/word.c@ffef79514d3c
children 166136236891
comparison
equal deleted inserted replaced
114:c82e7a7ef8d9 115:ca30f8334741
1 #include <ctype.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5
6 unsigned char* getWord(unsigned char *string) {
7 int wordSize = 0;
8 while (isalnum(string[wordSize])) {
9 wordSize++;
10 }
11
12 int allocateWordSize = wordSize + 1;
13 unsigned char *word = (unsigned char*)malloc(sizeof(unsigned char)*allocateWordSize);
14 strncpy((char*)word, (char*)string, allocateWordSize);
15 word[wordSize] = '\0';
16 return word;
17 }