When reading character data from an input stream, what is the difference between using the >> operator and using the `get` function?

Recommended Answers

All 4 Replies

get doesn't skip whitespace

get function just reads a character at a time, >> operator reads until new line is detected or otherwise specfiied. getline function reads all space on one line even white space

>> will pead data until a space character is met. this means that if u need to enter the address os sombody u cannot use>> u hav to use cin.getline. wtas the difference. wiz cin.getline u can enter all chracters including a space one

>> won't read white spaces. with gets u can.

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.