C ++ prototype (Win32 and Linux ):
#include <iostream>istream& getline ( istream &is , string &str , char delim );istream& getline ( istream& , string& );
Note:
Processing the terminator (the default line break is used as the terminator)
After the terminator delim is encountered, delim is discarded and not stored in Str. In the next read operation, the next character of delim is read.
Test code:
#include <iostream>#include <string>int read_line(void){ std::string buf; getline(std::cin, buf); std::cout << buf; return 0; }
C prototype (Linux ):
#include <stdio.h>ssize_t getline(char **lineptr, size_t *n, FILE *stream);
Test code:
#include <stdio.h>int read_line_c(void){ char buffer[100]; getline(buffer, sizeof(buffer), stdin); printf(buffer);}
Note:
Description
Getline () reads an entire line from stream, storing the address of
Buffer containing the text into * lineptr. The buffer is null-terminated and contains des the newline character, if one was found.
Used to read a line of character until the line break, including the line break
Note:
Related functions. For fgets () functions, line breaks and gets () functions are read on both platforms. line breaks are not read on both platforms.
Reference link:
Http://baike.baidu.com/view/3127321.htm
Http://baike.baidu.com/view/8684247.htm