When using >> to extract data from an istream, are spaces skipped over? I.e., if I extracted every character from: "Hello, my name is not World.", would the 5 spaces not be read by >>?

If so, is this behavior omitted from istream::get()?

Thanks.

Recommended Answers

All 3 Replies

You can easily test your question yourself. Write a small program to find out how the >> operator behaves. I could easily tell you, but testing it out yourself is a much better teacher.

You can easily test your question yourself. Write a small program to find out how the >> operator behaves. I could easily tell you, but testing it out yourself is a much better teacher.

I had tried it, and the results I got led me to believe that the behavior I asked about above is correct (ie, >>: no spaces, get: spaces). I was just confirming it.

You can use the std::noskipws stream manipulator to alter the behavior of the stream. See here.

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.