getline()

Get line from stream into string

  • Extracts characters from is and stores them into str until the delimitation character delim is found (or the newline character, ‘\n’, for (2)).

从is中提取字符并将其存储到str中,直到找到分隔符delim(或**换行符’\n’**,for(2))。

  • The extraction also stops if the end of file is reached in is or if some other error occurs during the input operation.

如果在中到达文件结尾,或者在输入操作期间发生其他错误,提取也会停止。

  • If the delimiter is found, it is extracted and discarded (i.e. it is not stored and the next input operation will begin after it).

如果找到分隔符,则会将其提取并丢弃(即不存储它,然后将开始下一个输入操作)。

  • Note that any content in str before the call is replaced by the newly extracted sequence.
    Each extracted character is appended to the string as if its member push_back was called.

请注意,调用之前str中的任何内容都将被新提取的序列替换。
每个提取的字符都附加到字符串中,就好像调用了其成员push_back一样。

指针

注意点

  1. 使用指针开辟数组时,一定要在使用前初始化值
  2. 使用指针才能够开辟动态数组,但是不太容易得到数组的长度