When you are writing a whilestatment like this you have ',' as a delimiter.
What I wonder is if it is possible to have more than only one delimiter as I also want at the same time use " " and ")". (a blank space and a ")" )

Is this possible ?

while( getline(ReadFile, OneString, ',')
{
}

I am trying out something like this but this does not work/compile:

char limiter = ( ',' ')' );

while( getline(ReadFile, OneString, limiter)
{
}

Recommended Answers

All 2 Replies

When you are writing a whilestatment like this you have ',' as a delimiter.
What I wonder is if it is possible to have more than only one delimiter as I also want at the same time use " " and ")". (a blank space and a ")" )

Is this possible ?

while( getline(ReadFile, OneString, ',')
{
}

I am trying out something like this but this does not work/compile:

char limiter = ( ',' ')' );

while( getline(ReadFile, OneString, limiter)
{
}

It's a superb question and one I have wondered often myself and one I don't really have an answer to. I do have an answer to the question as it pertains to getline and whether the above will work. The getline function from the istream library won't work. Here are your two options here:

istream& getline ( istream& is, string& str, char delim );
istream& getline ( istream& is, string& str );


http://www.cplusplus.com/reference/string/getline.html

There are equivalent varieties for C-style strings, but you only get to specify one delimiter in either case.

char limiter = ( ',' ')' );

This won't work. You can't stick two characters in a char since it only sets aside one byte of memory.

As to whether there is some function that someone somewhere has written and shared with the world that does what you want, there may well be one, and for all I know there may be one in the C++ standard, but it's not getline from istream.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.