Search code examples
c++visual-studiovisual-c++visual-c++-2010

Size of the line parameter


Is there any parameter that will read whole line from the input? I know there is getline(buffer, size_of_the_line) function, but I don't want to limit a size_of_the_line property to just the number I define, but limitless. Is there such a thing at all?

Thanks in advance.


Solution

  • Yes, a free function defined in <string> header:

    std::getline

    #include <iostream>
    #include <string>
    
    int main()
    {
        std::string line_of_input;
        std::getline(std::cin, line_of_input); // limited only by the max size of string
    }