Home > Back-end > Want to ask how the while loop is over?
Want to ask how the while loop is over?
Time:10-05
And how istringstream role, is to save the string, or the string into the input stream
CodePudding user response:
Getline of the first parameter is the input stream cost types, the second parameter string& Type receives input, heavy cut version of the third parameter is the space character, the default is of course a newline character '\ n'; Each invocation returns a line from the first parameter is the input stream to the second argument, if read by a line, returns true, don't read, return false, as to how to call a line, just said, when it returns false, of course, to read to the constant EOF (1), There are many kinds of, and the input stream, the standard input file input, input byte (string), cin is the global amount of standard input,
Istringstream is cost derived classes, in order to put the string into a string input stream can send ginseng to getline functions, look at its structure function of the first parameter is the string const reference string& , I don't know how to understand your so-called save string, How while loop end, of course, of the string input getline flow reading, read it a - 1, return false,
CodePudding user response:
Learned, but I still doubt getline the third parameter is the blank space, should not be read Spaces will return 1? Why can read a line
CodePudding user response:
Learned, but I still doubt getline the third parameter is the blank space, should not be read Spaces will return 1, why read to the end of the line to cycle