C++ :: Partial Tokenization From A Certain Position
Mar 14, 2013
I have a string like:
char *origin = "THIS, IS, SPARTA!"
What I want to do is get all characters in a string up to a certain delimiter, for that I've searched I can do that with:
sscanf
getline
strok
But what I don't know and haven't found is how to use these functions but to start reading from a certain position in the string. So I need to get the characters up to a comma but after "THIS," so that would be starting in position 5...
How could I do that? I tried using [x] in brackets but then it would just read a character...
View 5 Replies
Nov 28, 2013
I have created a program which does tokenization to the whole line. The basic idea is if you have this ***HELLO%%SIR.
Then you have 8 tokens (2 words + 6 symbols). My algorithm is the following :
BEGIN OF THE LOOP
IF CHARACTER IS NOT AN ALPHABETIC LETTER
INCREASE THE COUNTER OF ITEMS ONE TIME
INCREASE THE COUNTER OF ARRAY ONE TIME
END IF
[Code] ....
And here is the implementation :
[C] C Words Tokenizer - Pastebin.com
First of all it is not an exercise from university. It is my reflection. What is your opinion about that exercise? It is useful? Tokens must be only the words between delimiters? I am analyzing the whole line.
Secondly I want to print the symbols and the words I don't want to use strtok to do this because I think that function line_tokenizer will not reusable due to strtok and the fact that puts the '