cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Parsing by char
Parsing by char
Jan 27, 2009 at 4:14am UTC
vexstorm
(31)
I am trying to read a title in from a file... how would i parse by char to create the title or is there a way to make it read up to the delimiter??
ex.
The Red Field#319831
How would i go about getting The Red Field into a string??
thanks...
Jan 27, 2009 at 4:21am UTC
psault
(133)
Check out getline.
I would try something like:
1
2
3
ifstream infile(
"filename"
); string mystring; getline(infile, mystring,
'#'
);
~psault
Jan 27, 2009 at 8:21am UTC
Corpus
(99)
Or you may tokenize the string, i.e. divide it into bits that are seperated by characters you select.
See
http://oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html
section 7.3 on the issue.
Topic archived. No new replies allowed.