In my C++ code, I want to read from a text file (*.txt) and tokenize every entry. More specifically, I want to be able to read individual words from a file, such as "format", "stack", "Jason", "europe", etc.
I chose to use fstream
to perform this task, and I do not know how to set it's delimiter to the ones I want to use (space,
, as well as hyphens and even apostrophes as in "Mcdonal's"). I figured space and
are the default delimiters, but hyphens are not, but I want to treat them as delimiters so that when parsing the file, I will get words in "blah blah xxx animal--cat" as simply "blah", "blah", "xxx", "animal", "cat".
That is, I want to be able to get two strings from "stack-overflow", "you're", etc, and still be able to maintain
and space as delimiters at the same time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…