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

CodePudding user response:

reference 1st floor SDGHCHJ 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 the end of the while loop, of course, of the string input getline flow reading, read it a - 1, return false,
learned, but I still doubt the get the line the third parameter is the space, meet the space is not return 1 yet, why not end loop, but read the line before the end of the cycle?

CodePudding user response:

refer to the second floor Xiyx is me reply:
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
read space means finished reading a line, returns true, read to the end of the string is 1,

CodePudding user response:

Reading is over, is really finished reading a line is end,
  • Related