Mercurial > hg > Applications > Grep
annotate c/regexParser/word.c @ 117:166136236891 pairPro
add header files
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 25 Nov 2015 14:58:03 +0900 |
parents | ca30f8334741 |
children |
rev | line source |
---|---|
113 | 1 #include <ctype.h> |
2 #include <string.h> | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
117
166136236891
add header files
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
115
diff
changeset
|
5 #include "word.h" |
113 | 6 |
7 unsigned char* getWord(unsigned char *string) { | |
8 int wordSize = 0; | |
9 while (isalnum(string[wordSize])) { | |
10 wordSize++; | |
11 } | |
12 | |
13 int allocateWordSize = wordSize + 1; | |
14 unsigned char *word = (unsigned char*)malloc(sizeof(unsigned char)*allocateWordSize); | |
15 strncpy((char*)word, (char*)string, allocateWordSize); | |
16 word[wordSize] = '\0'; | |
17 return word; | |
18 } |