if cin.get(str,256); executes, why it reads only 255 characters???? answer immediately please

Recommended Answers

All 4 Replies

Because in this function the characters are extracted until either n-1 characters have been extracted or the delimiting character '\n' is found.
Here's a useful link on this topic: click me

Be careful. If cin.get() --but not cin.getline()-- reads an empty line it will set something called the failbit. The failbit prevents further input to cin.get(). Use cin.clear() to unset the failbit!

If you call cin.get() or cin.getline() and the input string is longer than the number of characters specified, these characters are put in a queue and will be submitted next time cin.get() or cin.getline() is called, but cin.getline() will also set the failbit. Be careful when you use these commands!

>>answer immediately please

Demanding immediate response is considered a very rude comment, which is probably the reason you got a negative rep for your post.

commented: It is indeed. +16

answer immediately please

strange phrase. what seems to be an order followed by a plea????

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.