C++ using multiple strtok() -
hello have following text:
htttp://zbw.eu/stw/descriptor/17782-1> htttp://www.w3.org/2004/02/skos/core#inscheme> htttp://zbw.eu/stw> . htttp://aims.fao.org/aos/agrovoc/c_2678> htttp://www.w3.org/2004/02/skos/core#exactmatch> htttp://zbw.eu/stw/descriptor/15918-5> . #komentar k totte hlouposti
..and fucntion tokenize data, when new line occurs:
bool iscorrect(char* buffer){ char* tok; tok = strtok( buffer,"\n"); while(tok != null){ bool = istriple(tok); tok = strtok(null, "\n"); } return true; }
when have separate token want tokenize more, tok sent function istriple(char * token):
bool istriple(char* token){ char* tok; tok = strtok(token, " "); while(tok != null){ tok = strtok(token, " "); } return true; }
in function input token divided more tokens when white space occurs. in function want theese new tokens send function multiply , create new smaller tokens..
the problem is, when call istriple(), wont create new smaller tokens. freezes.
can anynone tell me, wrong?
thank you.
on first call, function strtok
expects c string argument, first character used starting location scan tokens. in subsequent calls, function expects null pointer , uses position right after end of last token new starting location scanning.
so should not use function "simultaneously" several input strings.
see http://www.cplusplus.com/reference/cstring/strtok/ detailed description.
Comments
Post a Comment